Skip to contentSkip to conversation

Another slash at index size

PATCH Nguyễn Thái Ngọc Duy 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

I noticed that even with v4, we still duplicate a lot of info in the remaining fields. ce_uid and ce_guid for instance are unlikely to change ever between entries. So I attempt to store offsets between the previous entry instead. The result looks good. This is webkit index:

25M index-v2
14M index-v4
7.7M index-v5
4.5M index-v5.gz

gzip beats me naturally, we still have a lot of spare bits and we don't use dictionaries. But the code is simpler and should run faster than gzip.

Performance is improved too:

$ time GIT_INDEX_FILE=index-v2 ./git ls-files |head -n1 >/dev/null
real    0m0.437s
user    0m0.385s
sys     0m0.048s
$ time GIT_INDEX_FILE=index-v4 ./git ls-files |head -n1 >/dev/null
real    0m0.319s
user    0m0.277s
sys     0m0.040s
$ time GIT_INDEX_FILE=index-v5 ./git ls-files |head -n1 >/dev/null
real    0m0.250s
user    0m0.213s
sys     0m0.036s

Some details on the new format:

- in general varint is used to store numbers, unless we know the numbers are really big.
- flags is the first field on disk, it has extra bits to let git know what to do with the rest of the fields
- Many fields like ctime, mtime, uid, gid, dev, ino are stored as offsets
- ce_mode's special values 100644 and 100755 are stored in flags. So unless you use gitlinks or something else, ce_mode will not be stored.
- ce_namelen is no longer stored on disk
- pathname is compressed just like in v4

---
 cache.h      |   2 +-
 read-cache.c | 273 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 269 insertions(+), 6 deletions(-)
cache.h +1 -1
index e493563..6ab53e7 100644
@@ -106,7 +106,7 @@ struct cache_header {
 };
 
 #define INDEX_FORMAT_LB 2
-#define INDEX_FORMAT_UB 4
+#define INDEX_FORMAT_UB 5
 
 /*
  * The "cache_time" is just the low 32 bits of the
read-cache.c +268 -5

317 lines not on this page · raw message

Signature · 1 line
1.8.1.2.495.g3fdf5d5.dirty