git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Speed up git-notes show
@ 2024-02-05 20:49 Maarten Bosmans
  2024-02-05 20:49 ` [PATCH 1/4] notes: print note blob to stdout directly Maarten Bosmans
                   ` (5 more replies)
  0 siblings, 6 replies; 36+ messages in thread
From: Maarten Bosmans @ 2024-02-05 20:49 UTC (permalink / raw)
  To: git; +Cc: Teng Long

First time contributor here, trying my first git.git patch series.

BACKGROUND
  We have a script that runs a range of build tests for all new commits in the
  repository and adds a line to the commit note with the result from the test.
  Something along the lines of:
      occa-build-jit-gnu-cuda-develop: PASSED (<hostname>, 2024-01-01 00:00:00+01:00)
  Pretty useful to quickly check that all commits at least build, not only for
  master, but also in progress feature branches.  (a passing test suite is
  generally only required at the merge point)
    
PROBLEM
  The bash script loops over all remote refs and lists the commits newer than
  <N> days ago.  For each commit its note is read and grep'ed for an existing
  test name to see whether the build test needs to run again.  The `git note show`
  command that is in this loop nest only takes 14ms to execute, but as it is in
  a loop, those times add up.

ANALYSIS
  When asked to show a note for a specific commit, git looks up the blob hash
  for the note and executes `git show` with that hash.  That of course adds
  the child process overhead, but also causes the initialization of a lot of
  log related configuration, such as for decorations or the mailmap.  Simply
  outputting the blob directly in the main process reduces the run time by
  almost halve.

When looking through the git show implementation for useful stuff that command
does that should also be done when showing a note, I could only find the
`setup_pager()` call. All other git show functionality was related to showing
commits or other non-blob objects.

The only thing I was not 100% sure of was the textconv_object stuff.  From what
I could deduce was that this is only ever used on blobs that represent files in
a tree, not on blobs that represent note objects.  So I did not include any
textconv calls in the git notes code.

The first commit is the main one fixing performance. The other three are just
eliminating some overhead I noticed when going through the git notes code.


Maarten Bosmans (4):
  notes: print note blob to stdout directly
  notes: use exisisting function stream_blob_to_fd
  notes: do not clean up right before calling die()
  notes: use strbuf_attach to take ownership of the object contents

 builtin/notes.c | 37 ++++++++++---------------------------
 1 file changed, 10 insertions(+), 27 deletions(-)

-- 
2.35.3


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

end of thread, other threads:[~2024-02-20 11:40 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-05 20:49 [PATCH 0/4] Speed up git-notes show Maarten Bosmans
2024-02-05 20:49 ` [PATCH 1/4] notes: print note blob to stdout directly Maarten Bosmans
2024-02-06  3:44   ` Junio C Hamano
2024-02-06  9:55     ` Maarten Bosmans
2024-02-06 17:52       ` Junio C Hamano
2024-02-13  8:00         ` Jeff King
2024-02-13 17:35           ` Junio C Hamano
2024-02-15  5:26             ` Jeff King
2024-02-16  6:25               ` Junio C Hamano
2024-02-17  5:16                 ` Jeff King
2024-02-17  5:56                   ` Junio C Hamano
2024-02-17  6:09                     ` Jeff King
2024-02-15  7:46           ` Maarten Bosmans
2024-02-15 15:04             ` Jeff King
2024-02-17 12:45               ` Maarten Bosmans
2024-02-20  1:51                 ` Jeff King
2024-02-15  7:41         ` Maarten Bosmans
2024-02-06 13:55     ` Kristoffer Haugsbakk
2024-02-05 20:49 ` [PATCH 2/4] notes: use exisisting function stream_blob_to_fd Maarten Bosmans
2024-02-05 22:00   ` Eric Sunshine
2024-02-05 20:49 ` [PATCH 3/4] notes: do not clean up right before calling die() Maarten Bosmans
2024-02-05 20:49 ` [PATCH 4/4] notes: use strbuf_attach to take ownership of the object contents Maarten Bosmans
2024-02-06  7:08 ` [PATCH 0/4] Speed up git-notes show Kristoffer Haugsbakk
2024-02-06  8:51   ` Maarten Bosmans
2024-02-18 19:59 ` [PATCH v2 0/5] " Maarten Bosmans
2024-02-18 19:59   ` [PATCH v2 1/5] log: Move show_blob_object() to log.c Maarten Bosmans
2024-02-20  1:22     ` Junio C Hamano
2024-02-20  1:59       ` Jeff King
2024-02-20  3:03         ` Junio C Hamano
2024-02-20 11:40         ` Maarten Bosmans
2024-02-18 19:59   ` [PATCH v2 2/5] notes: avoid launching a child process to show a note blob Maarten Bosmans
2024-02-18 19:59   ` [PATCH v2 3/5] notes: use existing function stream_blob_to_fd Maarten Bosmans
2024-02-18 19:59   ` [PATCH v2 4/5] notes: do not clean up right before calling die() Maarten Bosmans
2024-02-18 19:59   ` [PATCH v2 5/5] notes: use strbuf_attach to take ownership of the object contents Maarten Bosmans
2024-02-20  2:12     ` Jeff King
2024-02-20  7:42       ` Maarten Bosmans

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).