git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] keep track of unresolved value of symbolic-ref in ref iterators
@ 2024-06-06 17:26 John Cai via GitGitGadget
  2024-06-06 17:26 ` [PATCH 1/4] refs: add referent parameter to refs_resolve_ref_unsafe John Cai via GitGitGadget
                   ` (4 more replies)
  0 siblings, 5 replies; 44+ messages in thread
From: John Cai via GitGitGadget @ 2024-06-06 17:26 UTC (permalink / raw)
  To: git; +Cc: Phillip Wood [ ]

For reftable development, it's useful to be able to print out the direct
value of a symbolic reference before resolution. This is currently possible
with git-for-each-ref, but since the iterators do not keep track of the
value of the symbolic ref, a separate call needs to be made each time making
it inefficient.

Address this inefficiency by keeping track of the value of the symbolic
reference in the ref iterator. This patch series also ends with a commit to
use this value in the iterator through callbacks in ref-filter.c.

This series started with [1] but I decided to send a separate patch series
since it is substantially different.

Benchmarking shows that with these changes, we experience a significant
speedup in git-for-each-ref(1):

$ hyperfine --warmup 5 "git for-each-ref --format='%(refname) %(objectname)
%(symref)'" "~/Projects/git/git for-each-ref --format='%(refname)
%(objectname) %(symref)'"

Benchmark 1: git for-each-ref --format='%(refname) %(objectname) %(symref)'
Time (mean ± σ): 210.0 ms ± 9.1 ms [User: 5.8 ms, System: 11.8 ms] Range
(min … max): 203.4 ms … 228.8 ms 12 runs

Benchmark 2: ~/Projects/git/git for-each-ref --format='%(refname)
%(objectname) %(symref)' Time (mean ± σ): 7.4 ms ± 0.7 ms [User: 2.6 ms,
System: 3.9 ms] Range (min … max): 5.9 ms … 11.7 ms 273 runs

Summary ~/Projects/git/git for-each-ref --format='%(refname) %(objectname)
%(symref)' ran 28.47 ± 2.86 times faster than git for-each-ref
--format='%(refname) %(objectname) %(symref)'

 1. https://lore.kernel.org/git/pull.1684.git.git.1709592718743.gitgitgadget@gmail.com/

John Cai (4):
  refs: add referent parameter to refs_resolve_ref_unsafe
  refs: keep track of unresolved reference value in iterators
  refs: add referent to each_ref_fn
  ref-filter: populate symref from iterator

 add-interactive.c           |  6 +++---
 bisect.c                    |  3 ++-
 blame.c                     |  4 ++--
 builtin/bisect.c            |  6 ++++--
 builtin/blame.c             |  2 +-
 builtin/branch.c            |  2 +-
 builtin/checkout.c          |  2 +-
 builtin/describe.c          |  2 +-
 builtin/fetch.c             |  3 ++-
 builtin/fsck.c              |  6 +++---
 builtin/gc.c                |  1 +
 builtin/log.c               |  1 +
 builtin/name-rev.c          |  2 +-
 builtin/pack-objects.c      |  5 +++--
 builtin/rebase.c            |  6 +++---
 builtin/receive-pack.c      |  4 ++--
 builtin/remote.c            |  6 ++++--
 builtin/repack.c            |  1 +
 builtin/replace.c           |  1 +
 builtin/rev-parse.c         |  4 ++--
 builtin/show-branch.c       |  8 ++++----
 builtin/show-ref.c          |  3 ++-
 builtin/stash.c             |  2 +-
 builtin/submodule--helper.c |  5 +++--
 builtin/symbolic-ref.c      |  2 +-
 builtin/worktree.c          |  1 +
 commit-graph.c              |  1 +
 config.c                    |  2 +-
 delta-islands.c             |  2 +-
 fetch-pack.c                |  2 ++
 help.c                      |  2 +-
 http-backend.c              |  5 +++--
 log-tree.c                  |  4 ++--
 ls-refs.c                   |  7 ++++---
 midx-write.c                |  2 +-
 negotiator/default.c        |  2 +-
 negotiator/skipping.c       |  2 +-
 notes.c                     |  2 +-
 object-name.c               |  2 +-
 reachable.c                 |  2 +-
 ref-filter.c                | 11 ++++++-----
 reflog.c                    |  1 +
 refs.c                      | 32 ++++++++++++++++++--------------
 refs.h                      |  3 ++-
 refs/files-backend.c        | 24 ++++++++++++++----------
 refs/iterator.c             |  5 ++++-
 refs/ref-cache.c            |  6 ++++++
 refs/ref-cache.h            |  2 ++
 refs/refs-internal.h        |  1 +
 refs/reftable-backend.c     |  6 +++---
 remote.c                    | 10 +++++-----
 replace-object.c            |  1 +
 revision.c                  |  4 ++--
 sequencer.c                 |  9 +++++----
 server-info.c               |  2 +-
 shallow.c                   |  2 ++
 submodule.c                 |  2 ++
 t/helper/test-ref-store.c   |  4 ++--
 transport-helper.c          |  1 +
 transport.c                 |  2 +-
 upload-pack.c               | 10 +++++-----
 walker.c                    |  1 +
 worktree.c                  |  6 ++++--
 63 files changed, 161 insertions(+), 109 deletions(-)


base-commit: 7b0defb3915eaa0bd118f0996e8c00b4eb2dc1ca
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1712%2Fjohn-cai%2Fjc%2Fsymbolic-ref-in-iterator-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1712/john-cai/jc/symbolic-ref-in-iterator-v1
Pull-Request: https://github.com/git/git/pull/1712
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2024-11-23  8:24 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-06 17:26 [PATCH 0/4] keep track of unresolved value of symbolic-ref in ref iterators John Cai via GitGitGadget
2024-06-06 17:26 ` [PATCH 1/4] refs: add referent parameter to refs_resolve_ref_unsafe John Cai via GitGitGadget
2024-06-06 18:21   ` Junio C Hamano
2024-06-06 18:23     ` Junio C Hamano
2024-06-07 13:43       ` John Cai
2024-06-07 15:21         ` Junio C Hamano
2024-06-10  7:29       ` Patrick Steinhardt
2024-06-10 18:09         ` Junio C Hamano
2024-06-06 21:02     ` John Cai
2024-06-06 22:44       ` Junio C Hamano
2024-06-28 15:30         ` Kristoffer Haugsbakk
2024-06-28 19:47           ` Junio C Hamano
2024-06-30 10:12             ` Linus Arver
2024-06-30 18:19               ` Junio C Hamano
2024-06-11  8:50   ` Jeff King
2024-07-30 14:38     ` John Cai
2024-06-06 17:26 ` [PATCH 2/4] refs: keep track of unresolved reference value in iterators John Cai via GitGitGadget
2024-06-11  9:01   ` Jeff King
2024-06-06 17:26 ` [PATCH 3/4] refs: add referent to each_ref_fn John Cai via GitGitGadget
2024-06-06 17:26 ` [PATCH 4/4] ref-filter: populate symref from iterator John Cai via GitGitGadget
2024-08-01 14:58 ` [PATCH v2 0/3] keep track of unresolved value of symbolic-ref in ref iterators John Cai via GitGitGadget
2024-08-01 14:58   ` [PATCH v2 1/3] refs: keep track of unresolved reference value in iterators John Cai via GitGitGadget
2024-08-01 16:41     ` Junio C Hamano
2024-08-05 10:59       ` Patrick Steinhardt
2024-08-05 15:40         ` Junio C Hamano
2024-08-01 14:58   ` [PATCH v2 2/3] refs: add referent to each_ref_fn John Cai via GitGitGadget
2024-08-01 14:58   ` [PATCH v2 3/3] ref-filter: populate symref from iterator John Cai via GitGitGadget
2024-08-01 16:43     ` Junio C Hamano
2024-08-01 16:51     ` Junio C Hamano
2024-08-01 16:54       ` Junio C Hamano
2024-08-06 19:49         ` John Cai
2024-08-06 20:17           ` Junio C Hamano
2024-08-07 19:42   ` [PATCH v3 0/3] keep track of unresolved value of symbolic-ref in ref iterators John Cai via GitGitGadget
2024-08-07 19:42     ` [PATCH v3 1/3] refs: keep track of unresolved reference value in iterators John Cai via GitGitGadget
2024-08-07 21:40       ` Junio C Hamano
2024-08-08 18:09         ` John Cai
2024-08-07 19:42     ` [PATCH v3 2/3] refs: add referent to each_ref_fn John Cai via GitGitGadget
2024-08-07 19:42     ` [PATCH v3 3/3] ref-filter: populate symref from iterator John Cai via GitGitGadget
2024-08-09 15:37     ` [PATCH v4 0/3] keep track of unresolved value of symbolic-ref in ref iterators John Cai via GitGitGadget
2024-08-09 15:37       ` [PATCH v4 1/3] refs: keep track of unresolved reference value in iterators John Cai via GitGitGadget
2024-11-23  8:24         ` shejialuo
2024-08-09 15:37       ` [PATCH v4 2/3] refs: add referent to each_ref_fn John Cai via GitGitGadget
2024-08-09 15:37       ` [PATCH v4 3/3] ref-filter: populate symref from iterator John Cai via GitGitGadget
2024-08-09 16:51       ` [PATCH v4 0/3] keep track of unresolved value of symbolic-ref in ref iterators Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).