Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit93ea719

Browse files
author
Daniel Shelepanov
committed
intermediate
1 parentf4c24d6 commit93ea719

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

‎engine.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,39 @@ ptrack_walkdir(const char *path, Oid tablespaceOid, Oid dbOid)
672672
FreeDir(dir);/* we ignore any error here */
673673
}
674674

675+
/*
676+
* Get a second position within ptrack map so that it fits
677+
* within the same cache line.
678+
*/
679+
size_t
680+
get_slot2(size_tslot1,uint64hash) {
681+
size_tcache_line_ep;// ending point of a cache line
682+
size_tcache_line_sp;// starting point of a cache line
683+
size_tcache_line_interval;
684+
size_tslot2;
685+
686+
/* Get the ending point of a cache line within entries[]. */
687+
cache_line_ep= (CACHE_LINE_ALIGN(offsetof(PtrackMapHdr,entries)+slot1*sizeof(XLogRecPtr))
688+
- offsetof(PtrackMapHdr,entries)) /sizeof(XLogRecPtr);
689+
/* handling an overflow beyond the entries boundary */
690+
cache_line_ep=cache_line_ep>PtrackContentNblocks ?PtrackContentNblocks :cache_line_ep;
691+
692+
/* Get the starting point of a cache line within entries[]. */
693+
cache_line_sp=cache_line_ep-ENTRIES_PER_LINE;
694+
695+
/* Handling overflow below zero (sp then must be larger than ep) */
696+
cache_line_sp=cache_line_sp>cache_line_ep ?0 :cache_line_sp;
697+
698+
cache_line_interval=cache_line_ep-cache_line_sp;
699+
slot2= (size_t)(cache_line_sp+ (((hash <<32) | (hash >>32)) %cache_line_interval));
700+
slot2= (slot1==slot2) ? ((slot1+1) %cache_line_interval) :slot2;
701+
returnslot2;
702+
}
703+
675704
/*
676705
* Mark modified block in ptrack_map.
677706
*/
707+
678708
void
679709
ptrack_mark_block(RelFileNodeBackendsmgr_rnode,
680710
ForkNumberforknum,BlockNumberblocknum)
@@ -703,7 +733,7 @@ ptrack_mark_block(RelFileNodeBackend smgr_rnode,
703733

704734
hash=BID_HASH_FUNC(bid);
705735
slot1= (size_t)(hash %PtrackContentNblocks);
706-
slot2=(size_t)(((hash <<32) | (hash >>32)) %PtrackContentNblocks);
736+
slot2=get_slot2(slot1,hash);
707737

708738
if (RecoveryInProgress())
709739
new_lsn=GetXLogReplayRecPtr(NULL);

‎engine.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
*/
4141
#definePTRACK_BUF_SIZE ((uint64) 8000)
4242

43+
/*
44+
* A reasonable assumption for most systems. Postgres core
45+
* leverages the same value for this purpose.
46+
*/
47+
#defineCACHE_LINE_SIZE64
48+
#defineCACHE_LINE_ALIGN(LEN)TYPEALIGN(CACHE_LINE_SIZE, (LEN))
49+
#defineENTRIES_PER_LINE(CACHE_LINE_SIZE/sizeof(XLogRecPtr))
50+
4351
/* Ptrack magic bytes */
4452
#definePTRACK_MAGIC "ptk"
4553
#definePTRACK_MAGIC_SIZE 4
@@ -117,6 +125,7 @@ extern void ptrack_mark_block(RelFileNodeBackend smgr_rnode,
117125
ForkNumberforkno,BlockNumberblkno);
118126

119127
externboolis_cfm_file_path(constchar*path);
128+
externsize_tget_slot2(size_tslot1,uint64hash);
120129
#ifdefPGPRO_EE
121130
externoff_tget_cfs_relation_file_decompressed_size(RelFileNodeBackendrnode,
122131
constchar*fullpath,ForkNumberforknum);

‎ptrack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS)
651651
/* Only probe the second slot if the first one is marked */
652652
if (update_lsn1 >=ctx->lsn)
653653
{
654-
slot2=(size_t)(((hash <<32) | (hash >>32)) %PtrackContentNblocks);
654+
slot2=get_slot2(slot1,hash);
655655
update_lsn2=pg_atomic_read_u64(&ptrack_map->entries[slot2]);
656656

657657
if (update_lsn2!=InvalidXLogRecPtr)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp