Skip to contentSkip to conversation

support for path name caching of blobs/trees in rev-cache

PATCH In review Nick Edelen 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 6/6 support for path name caching of blobs/trees in rev-cache

An update to caching mechanism, allowing path names to be cached for blob and tree objects. A list of names appearing in each cache slice is appended to the end of the slice, which is referenced by variable-sized indexes per entry. This allows pack-objects to more intelligently schedule unpacked/poorly packed object, and enables proper duplication of rev-list's behaivor.

The mechanism for this involves adding a 'name' field to blob and tree objects, mainly to facilitate reuse of caches during maintenence (like the 'unique' field).

---
 builtin-rev-cache.c       |    3 +-
 rev-cache.c               |  307 +++++++++++++++++++++++++++++++++++++--------
 rev-cache.h               |   13 ++-
 revision.h                |    6 +-
 t/t6015-rev-cache-list.sh |    4 +-
 tree.h                    |    1 +
 6 files changed, 274 insertions(+), 60 deletions(-)
builtin-rev-cache.c +2 -1
index 2db4a10..042cf08 100644
@@ -177,13 +177,14 @@ static int handle_walk(int argc, const char *argv[])
 	fprintf(stderr, "pending:\n");
 	for (i = 0; i < revs.pending.nr; i++) {
 		struct object *obj = revs.pending.objects[i].item;
+		const char *name = revs.pending.objects[i].name;
 		
 		/* unfortunately, despite our careful generation, object duplication *is* a possibility...
 		 * (eg. same object introduced into two different branches) */
 		if (obj->flags & SEEN)
 			continue;
 		
-		printf("%s\n", sha1_to_hex(revs.pending.objects[i].item->sha1));
+		printf("%s %s\n", sha1_to_hex(revs.pending.objects[i].item->sha1), name);
 		obj->flags |= SEEN;
 	}
 	
rev-cache.c +255 -52

575 lines not on this page · raw message

rev-cache.h +9 -4
index f0b7d57..0254db7 100644
@@ -13,9 +13,10 @@
 
 #define RC_OE_CAST(p)	((struct rc_object_entry *)(p))
 #define RC_IE_CAST(p)	((struct rc_index_entry *)(p))
-
-#define RC_ACTUAL_OBJECT_ENTRY_SIZE(e)		(RC_OE_SIZE + RC_PATH_SIZE((e)->merge_nr + (e)->split_nr) + (e)->size_size)
-#define RC_ENTRY_SIZE_OFFSET(e)			(RC_ACTUAL_OBJECT_ENTRY_SIZE(e) - (e)->size_size)
+
+#define RC_ACTUAL_OBJECT_ENTRY_SIZE(e)		(RC_OE_SIZE + RC_PATH_SIZE((e)->merge_nr + (e)->split_nr) + (e)->size_size + (e)->name_size)
+#define RC_ENTRY_SIZE_OFFSET(e)			(RC_ACTUAL_OBJECT_ENTRY_SIZE(e) - (e)->name_size - (e)->size_size)
+#define RC_ENTRY_NAME_OFFSET(e)			(RC_ACTUAL_OBJECT_ENTRY_SIZE(e) - (e)->name_size)
 
 /* single index maps objects to cache files */
 struct rc_index_header {
@@ -48,6 +49,8 @@ struct rc_slice_header {
 	uint32_t size;
 	
 	unsigned char sha1[20];
+	
+	uint32_t name_size;
 };
 
 struct rc_object_entry {
@@ -62,7 +65,8 @@ struct rc_object_entry {
 	unsigned char merge_nr; /* : 7 */
 	unsigned char split_nr; /* : 7 */
 	unsigned size_size : 3;
-	unsigned padding : 5;
+	unsigned name_size : 3;
+	unsigned padding : 2;
 	
 	uint32_t date;
 	uint16_t path;
@@ -70,6 +74,7 @@ struct rc_object_entry {
 	/* merge paths */
 	/* split paths */
 	/* size */
+	/* name id */
 };
 
 
revision.h +5 -1
index ec83aa0..a802c9b 100644
@@ -23,6 +23,9 @@ struct rev_cache_slice_map {
 	unsigned char *map;
 	int size;
 	int last_index;
+	
+	char *names;
+	int name_size;
 };
 
 struct rev_cache_info {
@@ -36,7 +39,8 @@ struct rev_cache_info {
 	unsigned overwrite_all : 1;
 	
 	/* traversal flags */
-	unsigned add_to_pending : 1;
+	unsigned add_to_pending : 1, 
+		add_names : 1;
 	
 	/* fuse options */
 	unsigned int ignore_size;
t/t6015-rev-cache-list.sh +2 -2
index fa6df21..ff36881 100755
@@ -4,8 +4,8 @@ test_description='git rev-cache tests'
 . ./test-lib.sh
 
 test_cmp_sorted() {
-	grep -io "[a-f0-9]*" $1 | sort >.tmpfile1 && 
-	grep -io "[a-f0-9]*" $2 | sort >.tmpfile2 && 
+	sort $1 >.tmpfile1 && 
+	sort $2 >.tmpfile2 && 
 	test_cmp .tmpfile1 .tmpfile2
 }
 
tree.h +1 -0
index 2ff01a4..6eb0cd0 100644
@@ -9,6 +9,7 @@ struct tree {
 	struct object object;
 	void *buffer;
 	unsigned long size;
+	char *name;
 };
 
 struct tree *lookup_tree(const unsigned char *sha1);
Signature · 1 line
tg: (bc19f4a..) t/revcache/names (depends on: t/revcache/docs)