Skip to content

Commit a7004ab

Browse files
pks-tgitster
authored andcommitted
refs: don't normalize log messages with REF_SKIP_CREATE_REFLOG
When the `REF_SKIP_CREATE_REFLOG` flag is set we skip the creation of the reflog entry, but we still normalize the reflog message when we queue the update. This is a waste of resources as the normalized message will never get used in the first place. Fix this issue by skipping the normalization in case the flag is set. This leads to a surprisingly large speedup when migrating from the "files" to the "reftable" backend: Benchmark 1: migrate files:reftable (refcount = 1000000, revision = HEAD~) Time (mean ± σ): 878.5 ms ± 14.9 ms [User: 726.5 ms, System: 139.2 ms] Range (min … max): 858.4 ms … 941.3 ms 50 runs Benchmark 2: migrate files:reftable (refcount = 1000000, revision = HEAD) Time (mean ± σ): 831.1 ms ± 10.5 ms [User: 694.1 ms, System: 126.3 ms] Range (min … max): 812.4 ms … 851.4 ms 50 runs Summary migrate files:reftable (refcount = 1000000, revision = HEAD) ran 1.06 ± 0.02 times faster than migrate files:reftable (refcount = 1000000, revision = HEAD~) And an ever larger speedup when migrating the other way round: Benchmark 1: migrate reftable:files (refcount = 1000000, revision = HEAD~) Time (mean ± σ): 923.6 ms ± 11.6 ms [User: 705.5 ms, System: 208.1 ms] Range (min … max): 905.3 ms … 946.5 ms 50 runs Benchmark 2: migrate reftable:files (refcount = 1000000, revision = HEAD) Time (mean ± σ): 818.5 ms ± 9.0 ms [User: 627.6 ms, System: 180.6 ms] Range (min … max): 802.2 ms … 842.9 ms 50 runs Summary migrate reftable:files (refcount = 1000000, revision = HEAD) ran 1.13 ± 0.02 times faster than migrate reftable:files (refcount = 1000000, revision = HEAD~) Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e4929cd commit a7004ab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

refs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,8 +1188,9 @@ struct ref_update *ref_transaction_add_update(
11881188
oidcpy(&update->new_oid, new_oid);
11891189
if ((flags & REF_HAVE_OLD) && old_oid)
11901190
oidcpy(&update->old_oid, old_oid);
1191+
if (!(flags & REF_SKIP_CREATE_REFLOG))
1192+
update->msg = normalize_reflog_message(msg);
11911193

1192-
update->msg = normalize_reflog_message(msg);
11931194
return update;
11941195
}
11951196

0 commit comments

Comments
 (0)