Skip to contentSkip to conversation

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

PATCH In review Nick Edelen 1 participant 2 messages 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).

---
This is a totally new patch to the series. I had somehow missed name caching earlier.

 blob.h                    |    1 +
 builtin-rev-cache.c       |    3 +-
 rev-cache.c               |  293 ++++++++++++++++++++++++++++++++++++++-------
 revision.h                |    3 +-
 t/t6015-rev-cache-list.sh |    4 +-
 tree.h                    |    1 +
 6 files changed, 259 insertions(+), 46 deletions(-)
blob.h +1 -0
index d8db96a..e6a46f3 100644
@@ -8,6 +8,7 @@ extern const char *blob_type;
 struct blob {
 	struct object object;
 	unsigned long size;
+	char *name;
 };
 
 struct blob *lookup_blob(const unsigned char *sha1);
builtin-rev-cache.c +2 -1
index 4a02af6..5f88214 100755
@@ -168,13 +168,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;
+		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 +251 -42

558 lines not on this page · raw message

revision.h +2 -1
index d97ac8c..5114208 100644
@@ -27,7 +27,8 @@ struct rev_cache_info {
 	
 	/* traversal flags */
 	unsigned save_unique : 1, 
-		add_to_pending : 1;
+		add_to_pending : 1, 
+		add_names : 1;
 	
 	/* fuse options */
 	unsigned int ignore_size;
t/t6015-rev-cache-list.sh +2 -2
index 561810f..3836596 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: (c47593c..) t/revcache/names (depends on: t/revcache/docs)
#1 lore raw

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.

---
 builtin-rev-cache.c       |    3 +-
 rev-cache.c               |  314 +++++++++++++++++++++++++++++++++++++--------
 rev-cache.h               |   16 ++-
 revision.h                |    6 +-
 t/t6015-rev-cache-list.sh |    4 +-
 5 files changed, 282 insertions(+), 61 deletions(-)
builtin-rev-cache.c +2 -1
index a3489ce..5ea5c6b 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 +260 -54

602 lines not on this page · raw message

rev-cache.h +13 -3
index 14437d8..c88ceae 100644
@@ -10,8 +10,14 @@
 #define RC_OBTAIN_OBJECT_ENTRY(p)			from_disked_rc_object_entry((struct rc_object_entry_ondisk *)(p), 0)
 #define RC_OBTAIN_INDEX_ENTRY(p)			from_disked_rc_index_entry((struct rc_index_entry_ondisk *)(p), 0)
 
-#define RC_ACTUAL_OBJECT_ENTRY_SIZE(e)		(sizeof(struct rc_object_entry_ondisk) + 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)	(\
+	sizeof(struct rc_object_entry_ondisk) + \
+	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 {
@@ -50,6 +56,8 @@ struct rc_slice_header {
 	uint32_t size;
 
 	unsigned char sha1[20];
+
+	uint32_t name_size;
 };
 
 struct rc_object_entry_ondisk {
@@ -76,7 +84,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;
@@ -84,6 +93,7 @@ struct rc_object_entry {
 	/* merge paths */
 	/* split paths */
 	/* size */
+	/* name id */
 };
 
 struct rc_index_entry *from_disked_rc_index_entry(struct rc_index_entry_ondisk *src, struct rc_index_entry *dst);
revision.h +5 -1
index c3ec1b3..b2d5834 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
 }
 
Signature · 1 line
tg: (e6091b4..) t/revcache/names (depends on: t/revcache/docs)