!81 add a parameter for batchread api

Merge pull request !81 from shipixian/dev_performance
This commit is contained in:
zoujia_yewu 2023-03-23 03:27:06 +00:00 committed by Gitee
commit d007438621
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 18 additions and 4 deletions

View File

@ -14220,7 +14220,11 @@ retry:
readOff = targetOff;
pgstat_report_wait_start(WAIT_EVENT_WAL_READ);
r = batchRead((uint8_t *) readBuf, ControlFile->checkPointCopy.ThisTimeLineID, targetOff);
bool walStoreToLocal = false;
if (EnableHotStandby && !push_standby)
walStoreToLocal = true;
r = batchRead((uint8_t *) readBuf, ControlFile->checkPointCopy.ThisTimeLineID, targetOff, walStoreToLocal);
pgstat_report_wait_end();
/*

View File

@ -1429,7 +1429,7 @@ He3DBWALRead(XLogReaderState *state,
pgstat_report_wait_start(WAIT_EVENT_WAL_READ);
#endif
nbytes = batchRead((uint8_t *) buf, state->currTLI, startptr);
nbytes = batchRead((uint8_t *) buf, state->currTLI, startptr, false);
#ifndef FRONTEND
pgstat_report_wait_end();

View File

@ -24,6 +24,7 @@
#include "storage/md.h"
#include "storage/smgr.h"
#include "storage/filecache.h"
#include "utils/hfs.h"
#include "utils/hsearch.h"
#include "utils/inval.h"
#include "utils/guc.h"
@ -446,6 +447,9 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
for (forknum = 0; forknum <= MAX_FORKNUM; forknum++)
smgrsw[which].smgr_unlink(rnodes[i], forknum, isRedo);
//remove unused pages and related wals in localdisk cache.
RemoveBufferFromLocal(rnodes[i].node.dbNode, rnodes[i].node.relNode, MAX_FORKNUM, 0);
}
pfree(rnodes);
@ -674,6 +678,8 @@ smgrtruncate(SMgrRelation reln, ForkNumber *forknum, int nforks, BlockNumber *nb
smgrsw[reln->smgr_which].smgr_truncate(reln, forknum[i], nblocks[i]);
//remove unused pages and related wals in localdisk cache.
RemoveBufferFromLocal(reln->smgr_rnode.node.dbNode, reln->smgr_rnode.node.relNode, forknum[i], nblocks[i]);
/*
* We might as well update the local smgr_cached_nblocks values. The
* smgr cache inval message that this function sent will cause other
@ -737,6 +743,9 @@ smgrtruncatelsn(SMgrRelation reln, ForkNumber *forknum, int nforks, BlockNumber
}
smgrsw[reln->smgr_which].smgr_truncate(reln, forknum[i], nblocks[i]);
//remove unused pages and related wals in localdisk cache.
RemoveBufferFromLocal(reln->smgr_rnode.node.dbNode, reln->smgr_rnode.node.relNode, forknum[i], nblocks[i]);
/*
* We might as well update the local smgr_cached_nblocks values. The
* smgr cache inval message that this function sent will cause other

View File

@ -52,7 +52,7 @@ extern Bufrd dataRead(int64_t fd,
extern void free_dataRead(uint8_t *buf, size_t count, size_t cap);
extern Bufrd readfs(int64_t fd, int64_t offset, uint32_t size);
extern int batchRead(uint8_t *buf, uint32_t timeline, uint64_t startPtr);
extern int batchRead(uint8_t *buf, uint32_t timeline, uint64_t startPtr, bool needStore);
extern uint8_t kvwrite(XLogItem *xlogItem);
extern uint8_t flushwals(XLogItem *xlogItem, uint32_t timeline);
extern uint8_t kvflush(XLogRecPtr lsn);
@ -62,4 +62,5 @@ extern Bufrd ReadWalsByPage(uint32_t dbid,
uint32_t blkno,
uint64_t startlsn,
uint64_t endlsn,
uint32_t timeline);
uint32_t timeline);
extern void RemoveBufferFromLocal(uint32_t dbid, uint32_t relid, uint32_t forkno, uint32_t blkno);