git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "John Cai via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Phillip Wood [ ]" <phillip.wood123@gmail.com>
Subject: [PATCH 0/4] keep track of unresolved value of symbolic-ref in ref iterators
Date: Thu, 06 Jun 2024 17:26:36 +0000	[thread overview]
Message-ID: <pull.1712.git.git.1717694800.gitgitgadget@gmail.com> (raw)

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

             reply	other threads:[~2024-06-06 17:26 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06 17:26 John Cai via GitGitGadget [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.1712.git.git.1717694800.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood123@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).