Skip to content

Commit

Permalink
util/paging: choose min paging size default value as 128, and max val…
Browse files Browse the repository at this point in the history
…ue as 8192 (#36331)

close #36328
  • Loading branch information
tiancaiamao authored Jul 19, 2022
1 parent a0cced2 commit 0cecfc8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
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

0 comments on commit 0cecfc8

Please sign in to comment.