Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge with the latest PG 16 sources as well as addition of the heap_merge.sh tool #18

Merged
merged 4 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/access/pg_tde_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,24 @@ RelationAddBlocks(Relation relation, BulkInsertState bistate,
*/
extend_by_pages += extend_by_pages * waitcount;

/* ---
* If we previously extended using the same bistate, it's very likely
* we'll extend some more. Try to extend by as many pages as
* before. This can be important for performance for several reasons,
* including:
*
* - It prevents mdzeroextend() switching between extending the
* relation in different ways, which is inefficient for some
* filesystems.
*
* - Contention is often intermittent. Even if we currently don't see
* other waiters (see above), extending by larger amounts can
* prevent future contention.
* ---
*/
if (bistate)
extend_by_pages = Max(extend_by_pages, bistate->already_extended_by);

/*
* Can't extend by more than MAX_BUFFERS_TO_EXTEND_BY, we need to pin
* them all concurrently.
Expand Down Expand Up @@ -325,7 +343,7 @@ RelationAddBlocks(Relation relation, BulkInsertState bistate,
* [auto]vacuum trying to truncate later pages as REL_TRUNCATE_MINIMUM is
* way larger.
*/
first_block = ExtendBufferedRelBy(EB_REL(relation), MAIN_FORKNUM,
first_block = ExtendBufferedRelBy(BMR_REL(relation), MAIN_FORKNUM,
bistate ? bistate->strategy : NULL,
EB_LOCK_FIRST,
extend_by_pages,
Expand Down Expand Up @@ -413,6 +431,7 @@ RelationAddBlocks(Relation relation, BulkInsertState bistate,
/* maintain bistate->current_buf */
IncrBufferRefCount(buffer);
bistate->current_buf = buffer;
bistate->already_extended_by += extend_by_pages;
}

return buffer;
Expand Down
2 changes: 1 addition & 1 deletion src/access/pg_tde_visibilitymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ vm_extend(Relation rel, BlockNumber vm_nblocks)
{
Buffer buf;

buf = ExtendBufferedRelTo(EB_REL(rel), VISIBILITYMAP_FORKNUM, NULL,
buf = ExtendBufferedRelTo(BMR_REL(rel), VISIBILITYMAP_FORKNUM, NULL,
EB_CREATE_FORK_IF_NEEDED |
EB_CLEAR_SIZE_CACHE,
vm_nblocks,
Expand Down
3 changes: 2 additions & 1 deletion src/access/pg_tdeam.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ pg_tde_gettup_advance_block(HeapScanDesc scan, BlockNumber block, ScanDirection
if (block == scan->rs_startblock)
return InvalidBlockNumber;

/* check if the limit imposed by pg_tde_setscanlimits() is met */
/* check if the limit imposed by heap_setscanlimits() is met */
if (scan->rs_numblocks != InvalidBlockNumber)
{
if (--scan->rs_numblocks == 0)
Expand Down Expand Up @@ -1781,6 +1781,7 @@ GetBulkInsertState(void)
bistate->current_buf = InvalidBuffer;
bistate->next_free = InvalidBlockNumber;
bistate->last_free = InvalidBlockNumber;
bistate->already_extended_by = 0;
return bistate;
}

Expand Down
13 changes: 10 additions & 3 deletions src/include/access/pg_tde_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,22 @@ typedef struct BulkInsertStateData
Buffer current_buf; /* current insertion target page */

/*
* State for bulk extensions. Further pages that were unused at the time
* of the extension. They might be in use by the time we use them though,
* so rechecks are needed.
* State for bulk extensions.
*
* last_free..next_free are further pages that were unused at the time of
* the last extension. They might be in use by the time we use them
* though, so rechecks are needed.
*
* XXX: Eventually these should probably live in RelationData instead,
* alongside targetblock.
*
* already_extended_by is the number of pages that this bulk inserted
* extended by. If we already extended by a significant number of pages,
* we can be more aggressive about extending going forward.
*/
BlockNumber next_free;
BlockNumber last_free;
uint32 already_extended_by;
} BulkInsertStateData;


Expand Down
2 changes: 1 addition & 1 deletion src/keyring/keyring_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int keyringFilePreloadCache(void)
return 1;
}

int keyringFileStoreKey(const keyInfo*)
int keyringFileStoreKey(const keyInfo* ki)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be unrelated to the merge?

{
// First very basic prototype: we just dump the cache to disk
FILE* f = fopen(keyringFileDataFileName, "w");
Expand Down
Loading
Loading