v18-0005-Remove-chunk-from-the-common-node-type.patch

application/x-patch

Filename: v18-0005-Remove-chunk-from-the-common-node-type.patch
Type: application/x-patch
Part: 2
Message: Re: [PoC] Improve dead tuple storage for lazy vacuum

Patch

Format: format-patch
Series: patch v18-0005
Subject: Remove chunk from the common node type
File+
src/include/lib/radixtree.h 5 9
From 4a385a0667e2489e6b4b850c2f7699049d652811 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Thu, 12 Jan 2023 20:32:06 +0700
Subject: [PATCH v18 05/10] Remove chunk from the common node type

This enabled a possible optimization for updating
the parent node's child pointer during node growth.
This is not likely to buy us much, and removing it
reduces the common type size to 5 bytes.

TODO: Reducing the smallest node to 3 members will
eliminate padding and only take up 32 bytes for
inner nodes.
---
 src/include/lib/radixtree.h | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/include/lib/radixtree.h b/src/include/lib/radixtree.h
index b3d84da033..72735c4643 100644
--- a/src/include/lib/radixtree.h
+++ b/src/include/lib/radixtree.h
@@ -295,7 +295,6 @@ typedef struct RT_NODE
 	 * RT_NODE_SPAN bits are then represented in chunk.
 	 */
 	uint8		shift;
-	uint8		chunk;
 
 	/* Node kind, one per search/set algorithm */
 	uint8		kind;
@@ -964,7 +963,6 @@ static inline void
 RT_COPY_NODE(RT_PTR_LOCAL newnode, RT_PTR_LOCAL oldnode)
 {
 	newnode->shift = oldnode->shift;
-	newnode->chunk = oldnode->chunk;
 	newnode->count = oldnode->count;
 }
 
@@ -1026,7 +1024,6 @@ static void
 RT_REPLACE_NODE(RT_RADIX_TREE *tree, RT_PTR_LOCAL parent, RT_PTR_ALLOC old_child,
 				RT_PTR_ALLOC new_child, uint64 key)
 {
-	Assert(old_child->chunk == new_child->chunk);
 	Assert(old_child->shift == new_child->shift);
 
 	if (parent == old_child)
@@ -1074,8 +1071,8 @@ RT_EXTEND(RT_RADIX_TREE *tree, uint64 key)
 		n4->base.chunks[0] = 0;
 		n4->children[0] = tree->root;
 
-		tree->root->chunk = 0;
-		tree->root = node;
+		/* Update the root */
+		tree->ctl->root = allocnode;
 
 		shift += RT_NODE_SPAN;
 	}
@@ -1104,8 +1101,7 @@ RT_SET_EXTEND(RT_RADIX_TREE *tree, uint64 key, uint64 value, RT_PTR_LOCAL parent
 		newchild = (RT_PTR_LOCAL) allocchild;
 		RT_INIT_NODE(newchild, RT_NODE_KIND_4, RT_CLASS_4_FULL, inner);
 		newchild->shift = newshift;
-		newchild->chunk = RT_GET_KEY_CHUNK(key, node->shift);
-		RT_NODE_INSERT_INNER(tree, parent, node, key, newchild);
+		RT_NODE_INSERT_INNER(tree, parent, nodep, node, key, allocchild);
 
 		parent = node;
 		node = newchild;
@@ -1684,13 +1680,13 @@ rt_dump_node(RT_PTR_LOCAL node, int level, bool recurse)
 {
 	char		space[125] = {0};
 
-	fprintf(stderr, "[%s] kind %d, fanout %d, count %u, shift %u, chunk 0x%X:\n",
+	fprintf(stderr, "[%s] kind %d, fanout %d, count %u, shift %u:\n",
 			NODE_IS_LEAF(node) ? "LEAF" : "INNR",
 			(node->kind == RT_NODE_KIND_4) ? 4 :
 			(node->kind == RT_NODE_KIND_32) ? 32 :
 			(node->kind == RT_NODE_KIND_125) ? 125 : 256,
 			node->fanout == 0 ? 256 : node->fanout,
-			node->count, node->shift, node->chunk);
+			node->count, node->shift);
 
 	if (level > 0)
 		sprintf(space, "%*c", level * 4, ' ');
-- 
2.39.0