support for path name caching of blobs/trees in rev-cache
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
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
@@ -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
@@ -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
@@ -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
@@ -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)