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

Commit33a3f33

Browse files
author
Daniel Shelepanov
committed
some refactoring
1 parentdf955c6 commit33a3f33

File tree

2 files changed

+17
-32
lines changed

2 files changed

+17
-32
lines changed

‎engine.c

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -692,38 +692,29 @@ ptrack_walkdir(const char *path, Oid tablespaceOid, Oid dbOid)
692692
*/
693693
size_t
694694
get_slot2(size_tslot1,uint64hash) {
695-
size_tcache_line_ep;// ending point of a cache line
696-
size_tcache_line_sp;// starting point of a cache line
697-
size_tcache_line_interval;
695+
size_tmemory_page_ep;// ending point of a cache line
696+
size_tmemory_page_sp;// starting point of a cache line
697+
size_tmemory_page_interval;
698698
size_tslot2;
699699

700-
/* Get the ending point of acache line within entries[]. */
701-
cache_line_ep= (CACHE_LINE_ALIGN(offsetof(PtrackMapHdr,entries)+slot1*sizeof(XLogRecPtr))
702-
- offsetof(PtrackMapHdr,entries)) /sizeof(XLogRecPtr);
700+
/* Get the ending point of amemory page within entries[]. */
701+
memory_page_ep= (MEMORY_PAGE_ALIGN(offsetof(PtrackMapHdr,entries)+slot1*sizeof(uint32))
702+
- offsetof(PtrackMapHdr,entries)) /sizeof(uint32);
703703
/* handling an overflow beyond the entries boundary */
704-
cache_line_ep=cache_line_ep>PtrackContentNblocks ?PtrackContentNblocks :cache_line_ep;
704+
memory_page_ep=memory_page_ep>PtrackContentNblocks ?PtrackContentNblocks :memory_page_ep;
705705

706706
/* Get the starting point of a cache line within entries[]. */
707-
cache_line_sp=cache_line_ep-ENTRIES_PER_LINE;
707+
memory_page_sp=memory_page_ep-ENTRIES_PER_PAGE;
708708

709709
/* Handling overflow below zero (sp then must be larger than ep) */
710-
cache_line_sp=cache_line_sp>cache_line_ep ?0 :cache_line_sp;
710+
memory_page_sp=memory_page_sp>memory_page_ep ?0 :memory_page_sp;
711711

712-
cache_line_interval=cache_line_ep-cache_line_sp;
713-
slot2= (size_t)(cache_line_sp+ (((hash <<32) | (hash >>32)) %cache_line_interval));
714-
slot2= (slot1==slot2) ? ((slot1+1) %cache_line_interval) :slot2;
712+
memory_page_interval=memory_page_ep-memory_page_sp;
713+
slot2= (size_t)(memory_page_sp+ (((hash <<32) | (hash >>32)) %memory_page_interval));
714+
slot2= (slot1==slot2) ? ((slot1+1) %memory_page_interval) :slot2;
715715
returnslot2;
716716
}
717717

718-
/*
719-
* Mark modified block in ptrack_map.
720-
*/
721-
staticvoidswap_slots(size_t*slot1,size_t*slot2) {
722-
*slot1 ^=*slot2;
723-
*slot2=*slot1 ^*slot2;
724-
*slot1=*slot1 ^*slot2;
725-
}
726-
727718
staticvoid
728719
ptrack_mark_map_pair(size_tslot1,size_tslot2,uint32new_lsn32)
729720
{
@@ -786,10 +777,7 @@ ptrack_mark_block(RelFileNodeBackend smgr_rnode,
786777
bid.blocknum=InvalidBlockNumber;
787778
hash=BID_HASH_FUNC(bid);
788779
max_lsn_slot1= (size_t)(hash %PtrackContentNblocks);
789-
max_lsn_slot2=max_lsn_slot1+1;
790-
791-
if (max_lsn_slot2<max_lsn_slot1)
792-
swap_slots(&max_lsn_slot1,&max_lsn_slot2);
780+
max_lsn_slot2= (max_lsn_slot1+1) %PtrackContentNblocks;
793781

794782
if (RecoveryInProgress())
795783
new_lsn=GetXLogReplayRecPtr(NULL);
@@ -830,10 +818,7 @@ XLogRecPtr ptrack_read_file_maxlsn(RelFileNode rnode, ForkNumber forknum)
830818
hash=BID_HASH_FUNC(bid);
831819

832820
slot1= (size_t)(hash %PtrackContentNblocks);
833-
slot2=slot1+1;
834-
835-
if (slot2<slot1)
836-
swap_slots(&slot1,&slot2);
821+
slot2= (slot1+1) %PtrackContentNblocks;
837822

838823
update_lsn1=pg_atomic_read_u32(&ptrack_map->entries[slot1]);
839824
update_lsn2=pg_atomic_read_u32(&ptrack_map->entries[slot2]);

‎engine.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
* A reasonable assumption for most systems. Postgres core
4545
* leverages the same value for this purpose.
4646
*/
47-
#defineCACHE_LINE_SIZE64
48-
#defineCACHE_LINE_ALIGN(LEN)TYPEALIGN(CACHE_LINE_SIZE, (LEN))
49-
#defineENTRIES_PER_LINE(CACHE_LINE_SIZE/sizeof(XLogRecPtr))
47+
#defineMEMORY_PAGE_SIZE4096
48+
#defineMEMORY_PAGE_ALIGN(LEN)TYPEALIGN(MEMORY_PAGE_SIZE, (LEN))
49+
#defineENTRIES_PER_PAGE(MEMORY_PAGE_SIZE/sizeof(XLogRecPtr))
5050

5151
/* Ptrack magic bytes */
5252
#definePTRACK_MAGIC "ptk"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp