summaryrefslogtreecommitdiff
path: root/object-store.h
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2019-01-06 16:45:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-08 17:40:19 (GMT)
commit4cea1ce0f69d079819f2a189febcea215045dabf (patch)
tree45a878f31890e63ee18602a49eb1c998a1399ea1 /object-store.h
parentd4e19e516325e211cedb070a487453ad2d1043be (diff)
downloadgit-4cea1ce0f69d079819f2a189febcea215045dabf.zip
git-4cea1ce0f69d079819f2a189febcea215045dabf.tar.gz
git-4cea1ce0f69d079819f2a189febcea215045dabf.tar.bz2
object-store: use one oid_array per subdirectory for loose cache
The loose objects cache is filled one subdirectory at a time as needed. It is stored in an oid_array, which has to be resorted after each add operation. So when querying a wide range of objects, the partially filled array needs to be resorted up to 255 times, which takes over 100 times longer than sorting once. Use one oid_array for each subdirectory. This ensures that entries have to only be sorted a single time. It also avoids eight binary search steps for each cache lookup as a small bonus. The cache is used for collision checks for the log placeholders %h, %t and %p, and we can see the change speeding them up in a repository with ca. 100 objects per subdirectory: $ git count-objects 26733 objects, 68808 kilobytes Test HEAD^ HEAD -------------------------------------------------------------------- 4205.1: log with %H 0.51(0.47+0.04) 0.51(0.49+0.02) +0.0% 4205.2: log with %h 0.84(0.82+0.02) 0.60(0.57+0.03) -28.6% 4205.3: log with %T 0.53(0.49+0.04) 0.52(0.48+0.03) -1.9% 4205.4: log with %t 0.84(0.80+0.04) 0.60(0.59+0.01) -28.6% 4205.5: log with %P 0.52(0.48+0.03) 0.51(0.50+0.01) -1.9% 4205.6: log with %p 0.85(0.78+0.06) 0.61(0.56+0.05) -28.2% 4205.7: log with %h-%h-%h 0.96(0.92+0.03) 0.69(0.64+0.04) -28.1% Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-store.h')
-rw-r--r--object-store.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/object-store.h b/object-store.h
index 709bf85..2fb6c0e 100644
--- a/object-store.h
+++ b/object-store.h
@@ -20,7 +20,7 @@ struct object_directory {
* Be sure to call odb_load_loose_cache() before using.
*/
char loose_objects_subdir_seen[256];
- struct oid_array loose_objects_cache;
+ struct oid_array loose_objects_cache[256];
/*
* Path to the alternative object store. If this is a relative path,