From 0cecfc85afe7fdcb8ac397f9b8e50ab01b6a7f93 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Tue, 19 Jul 2022 21:57:08 +0800 Subject: [PATCH] util/paging: choose min paging size default value as 128, and max value as 8192 (#36331) close pingcap/tidb#36328 --- util/paging/paging.go | 9 ++++----- util/paging/paging_test.go | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/util/paging/paging.go b/util/paging/paging.go index 5f2618ea341db..510e1847fbc2b 100644 --- a/util/paging/paging.go +++ b/util/paging/paging.go @@ -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 ) diff --git a/util/paging/paging_test.go b/util/paging/paging_test.go index 1890b4d754d54..6d9bba9121e86 100644 --- a/util/paging/paging_test.go +++ b/util/paging/paging_test.go @@ -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) {