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

Commit3e70da2

Browse files
committed
Always use the caller-provided context for radix tree leaves
Previously, it would not have worked for a caller to pass a slabcontext, since it would have been used for other things which likelyhad incompatible size. In an attempt to be helpful and avoid possiblespace wastage due to aset's power-of-two rounding, RT_CREATE wouldcreate an additional slab context if the value type was fixed-lengthand larger than pointer size. The problem was, we have since addedthe bump context type, and the generation context was a possibility aswell, so silently overriding the caller's choice may actually be worse.Commite8a6f1f arranged so that the caller-provided context isused only for leaves, so it's safe for the caller to use slab hereif they wish. As demonstration, use slab in one of the radix treeregression tests.Reviewed by Masahiko SawadaDiscussion:https://postgr.es/m/CANWCAZZDCo4k5oURg_pPxM6+WZ1oiG=sqgjmQiELuyP0Vtrwig@mail.gmail.com
1 parente8a6f1f commit3e70da2

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

‎src/include/lib/radixtree.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,21 +1849,7 @@ RT_CREATE(MemoryContext ctx)
18491849
size_class.allocsize);
18501850
}
18511851

1852-
/* By default we use the passed context for leaves. */
18531852
tree->leaf_context=ctx;
1854-
1855-
#ifndefRT_VARLEN_VALUE_SIZE
1856-
1857-
/*
1858-
* For leaves storing fixed-length values, we use a slab context to avoid
1859-
* the possibility of space wastage by power-of-2 rounding up.
1860-
*/
1861-
if (sizeof(RT_VALUE_TYPE)>sizeof(RT_PTR_ALLOC))
1862-
tree->leaf_context=SlabContextCreate(ctx,
1863-
RT_STR(RT_PREFIX)"_radix_tree leaf context",
1864-
RT_SLAB_BLOCK_SIZE(sizeof(RT_VALUE_TYPE)),
1865-
sizeof(RT_VALUE_TYPE));
1866-
#endif/* !RT_VARLEN_VALUE_SIZE */
18671853
#endif/* RT_SHMEM */
18681854

18691855
/* add root node now so that RT_SET can assume it exists */

‎src/test/modules/test_radixtree/test_radixtree.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,10 @@ test_random(void)
313313
#else
314314
MemoryContextradixtree_ctx;
315315

316-
radixtree_ctx=AllocSetContextCreate(CurrentMemoryContext,
317-
"test_radix_tree",
318-
ALLOCSET_SMALL_SIZES);
316+
radixtree_ctx=SlabContextCreate(CurrentMemoryContext,
317+
"test_radix_tree",
318+
SLAB_DEFAULT_BLOCK_SIZE,
319+
sizeof(TestValueType));
319320
radixtree=rt_create(radixtree_ctx);
320321
#endif
321322

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp