Add readahead_distance GUC

This commit is contained in:
Konstantin Knizhnik
2023-06-22 12:35:50 +03:00
parent f88ff9f3c6
commit b3ef6c7bf5
4 changed files with 15 additions and 2 deletions

View File

@@ -49,7 +49,6 @@ static int max_access_stat_count;
static double min_seq_access_ratio;
static int min_seq_access_count;
void access_stat_init(void)
{
MemoryContext memctx = AllocSetContextCreate(TopMemoryContext,

View File

@@ -58,6 +58,7 @@ char *neon_auth_token;
int n_unflushed_requests = 0;
int flush_every_n_requests = 8;
int readahead_buffer_size = 128;
int readahead_distance = 10;
bool (*old_redo_read_buffer_filter) (XLogReaderState *record, uint8 block_id) = NULL;
@@ -452,6 +453,18 @@ pg_init_libpagestore(void)
PGC_USERSET,
0, /* no flags required */
NULL, (GucIntAssignHook) &readahead_buffer_resize, NULL);
DefineCustomIntVariable("neon.readahead_distance",
"Number of read-ahead blocks",
NULL,
&readahead_distance,
10,
0,
INT_MAX,
PGC_USERSET,
0,
NULL,
NULL,
NULL);
relsize_hash_init();

View File

@@ -157,6 +157,7 @@ extern page_server_api * page_server;
extern char *page_server_connstring;
extern int flush_every_n_requests;
extern int readahead_buffer_size;
extern int readahead_distance = 10;
extern bool seqscan_prefetch_enabled;
extern int seqscan_prefetch_distance;
extern char *neon_timeline;

View File

@@ -2006,7 +2006,7 @@ neon_read(SMgrRelation reln, ForkNumber forkNum, BlockNumber blkno,
/* If it is expected to be sequential access then initiate prefetch of next block */
if (is_sequential_access(reln->smgr_rnode.node, forkNum, blkno))
neon_prefetch(reln, forkNum, blkno+1);
neon_prefetch(reln, forkNum, blkno + readahead_distance);
/* Try to read from local file cache */
if (lfc_read(reln->smgr_rnode.node, forkNum, blkno, buffer))