Skip to content

Commit 4af31dc

Browse files
pks-tgitster
authored andcommitted
refs/reftable: skip duplicate name checks
All the callback functions which write refs in the reftable backend perform D/F conflict checks via `refs_verify_refname_available()`. But in reality we perform these D/F conflict checks a second time in the reftable library via `stack_check_addition()`. Interestingly, the code in the reftable library is inferior compared to the generic function: - It is slower than `refs_verify_refname_available()`, even though this can probably be optimized. - It does not provide a proper error message to the caller, and thus all the user would see is a generic "file/directory conflict" message. Disable the D/F conflict checks in the reftable library by setting the `skip_name_check` write option. This results in a non-negligible speedup when writing many refs. The following benchmark writes 100k refs in a single transaction: Benchmark 1: update-ref: create many refs (HEAD~) Time (mean ± σ): 3.241 s ± 0.040 s [User: 1.854 s, System: 1.381 s] Range (min … max): 3.185 s … 3.454 s 100 runs Benchmark 2: update-ref: create many refs (HEAD) Time (mean ± σ): 2.878 s ± 0.024 s [User: 1.506 s, System: 1.367 s] Range (min … max): 2.838 s … 2.960 s 100 runs Summary update-ref: create many refs (HEAD~) ran 1.13 ± 0.02 times faster than update-ref: create many refs (HEAD) Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 455d61b commit 4af31dc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

refs/reftable-backend.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ static struct ref_store *reftable_be_init(struct repository *repo,
247247
refs->write_options.block_size = 4096;
248248
refs->write_options.hash_id = repo->hash_algo->format_id;
249249
refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
250+
/*
251+
* We verify names via `refs_verify_refname_available()`, so there is
252+
* no need to do the same checks in the reftable library again.
253+
*/
254+
refs->write_options.skip_name_check = 1;
250255

251256
/*
252257
* Set up the main reftable stack that is hosted in GIT_COMMON_DIR.

0 commit comments

Comments
 (0)