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

Appearance settings

Commit cf8e309

Browse filesBrowse files
committed
Slightly optimize ptrack_get_pagemapset
Probe the second slot only if the first one succeded.
1 parent 3026be9 commit cf8e309
Copy full SHA for cf8e309

File tree

Expand file treeCollapse file tree

1 file changed

+14
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-9
lines changed

‎ptrack.c

Copy file name to clipboardExpand all lines: ptrack.c
+14-9Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -532,24 +532,29 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS)
532532

533533
hash = BID_HASH_FUNC(ctx->bid);
534534
slot1 = hash % PtrackContentNblocks;
535-
slot2 = ((hash << 32) | (hash >> 32)) % PtrackContentNblocks;
536535

537536
update_lsn1 = pg_atomic_read_u64(&ptrack_map->entries[slot1]);
538-
update_lsn2 = pg_atomic_read_u64(&ptrack_map->entries[slot2]);
539537

540538
if (update_lsn1 != InvalidXLogRecPtr)
541539
elog(DEBUG3, "ptrack: update_lsn1 %X/%X of blckno %u of file %s",
542540
(uint32) (update_lsn1 >> 32), (uint32) update_lsn1,
543541
ctx->bid.blocknum, ctx->relpath);
544542

545-
if (update_lsn2 != InvalidXLogRecPtr)
546-
elog(DEBUG3, "ptrack: update_lsn2 %X/%X of blckno %u of file %s",
547-
(uint32) (update_lsn1 >> 32), (uint32) update_lsn2,
548-
ctx->bid.blocknum, ctx->relpath);
543+
/* Only probe the second slot if the first one is marked */
544+
if (update_lsn1 >= ctx->lsn)
545+
{
546+
slot2 = ((hash << 32) | (hash >> 32)) % PtrackContentNblocks;
547+
update_lsn2 = pg_atomic_read_u64(&ptrack_map->entries[slot2]);
549548

550-
/* Block has been changed since specified LSN. Mark it in the bitmap */
551-
if (update_lsn1 >= ctx->lsn && update_lsn2 >= ctx->lsn)
552-
datapagemap_add(&pagemap, ctx->bid.blocknum % ((BlockNumber) RELSEG_SIZE));
549+
if (update_lsn2 != InvalidXLogRecPtr)
550+
elog(DEBUG3, "ptrack: update_lsn2 %X/%X of blckno %u of file %s",
551+
(uint32) (update_lsn1 >> 32), (uint32) update_lsn2,
552+
ctx->bid.blocknum, ctx->relpath);
553+
554+
/* Block has been changed since specified LSN. Mark it in the bitmap */
555+
if (update_lsn2 >= ctx->lsn)
556+
datapagemap_add(&pagemap, ctx->bid.blocknum % ((BlockNumber) RELSEG_SIZE));
557+
}
553558

554559
ctx->bid.blocknum += 1;
555560
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.