Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions util/paging/paging.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ package paging
import "math"

// A paging request may be separated into multi requests if there are more data than a page.
// The paging size grows from min to max, it's not well tuned yet.
// e.g. a paging request scans over range (r1, r200), it requires 64 rows in the first batch,
// The paging size grows from min to max. See https://github.com/pingcap/tidb/issues/36328
// e.g. a paging request scans over range (r1, r200), it requires 128 rows in the first batch,
// if it's not drained, then the paging size grows, the new range is calculated like (r100, r200), then send a request again.
// Compare with the common unary request, paging request allows early access of data, it offers a streaming-like way processing data.
// TODO: may make the paging parameters configurable.
const (
MinPagingSize uint64 = 64
MinPagingSize uint64 = 128
maxPagingSizeShift = 7
pagingSizeGrow = 2
MaxPagingSize = MinPagingSize << maxPagingSizeShift
MaxPagingSize = 8192
pagingGrowingSum = ((2 << maxPagingSizeShift) - 1) * MinPagingSize
Threshold uint64 = 960
)
Expand Down
4 changes: 2 additions & 2 deletions util/paging/paging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

func TestGrowPagingSize(t *testing.T) {
require.Equal(t, GrowPagingSize(MinPagingSize), MinPagingSize*pagingSizeGrow)
require.Equal(t, GrowPagingSize(MaxPagingSize), MaxPagingSize)
require.Equal(t, GrowPagingSize(MaxPagingSize/pagingSizeGrow+1), MaxPagingSize)
require.Equal(t, GrowPagingSize(MaxPagingSize), uint64(MaxPagingSize))
require.Equal(t, GrowPagingSize(MaxPagingSize/pagingSizeGrow+1), uint64(MaxPagingSize))
}

func TestCalculateSeekCnt(t *testing.T) {
Expand Down