From: Toon Claes <toon@iotcl.com>
To: Karthik Nayak <karthik.188@gmail.com>, git@vger.kernel.org
Cc: Karthik Nayak <karthik.188@gmail.com>
Subject: Re: [PATCH v2] packed-refs: use `fwrite()` when passing refs verbatim
Date: Mon, 05 Oct 2026 20:34:32 +0200 [thread overview]
Message-ID: <87zewsf13b.fsf@dev.null.iotcl.com.invalid> (raw)
In-Reply-To: <20261002-kn-speedup-packed-refs-v2-1-2ae75772ebc1@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
> The `write_with_updates()` function uses a `struct ref_iterator` to
> iterate over all refs to write to the temporary packed-refs file. It
> receives the iterator from `packed_ref_iterator_begin()` which takes a
> snapshot of the 'packed-refs' file.
>
> While writing to the new packed-refs file, writes are routed via
> `write_packed_entry()` which uses `fprintf()`. Even for references which
> haven't changed, we use the same mechanism. Instead, let's track the
> position of unchanged references in the snapshot iterator and directly
> use `fwrite()`.
>
> With this, any sanitation which was happening as a side of reformatting
s/side/side effect/ ?
> is now lost. But that was never the job of this section of the code,
> since the main intention is to simply rewrite the remaining refs post
> deletion of the selective few.
Agreed.
>
> This removes the unnecessary formatting operation involved. We can see a
> consistent ~20% performance improvement when deleting from packed
> references.
>
> Benchmark 1: update-ref: delete ref (refcount = 100000, revision = master)
> Time (mean ± σ): 28.7 ms ± 1.7 ms [User: 22.5 ms, System: 5.9 ms]
> Range (min … max): 26.7 ms … 33.3 ms 46 runs
>
> Benchmark 2: update-ref: delete ref (refcount = 100000, revision = b4/kn-speedup-packed-refs)
> Time (mean ± σ): 23.8 ms ± 1.2 ms [User: 17.5 ms, System: 6.0 ms]
> Range (min … max): 22.1 ms … 27.7 ms 56 runs
>
> Summary
> update-ref: delete ref (refcount = 100000, revision = b4/kn-speedup-packed-refs) ran
> 1.21 ± 0.09 times faster than update-ref: delete ref (refformat = files, refcount = 100000, revision = master)
>
> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
> ---
> Changes in v2:
> - Instead of using the existing function, introduce a new
> `write_packed_entry_raw()`.
> - Modify the commit to also note that we lose sanitization.
s/commit/commit message/
> - Link to v1: https://patch.msgid.link/20260930-kn-speedup-packed-refs-v1-1-111cd03d9b0e@gmail.com
Okay, I'm okay with this version.
--
Laters,
Toon
next prev parent reply other threads:[~2026-10-05 18:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 15:15 [PATCH] packed-refs: use `fwrite()` when passing refs verbatim Karthik Nayak
2026-10-01 20:30 ` Toon Claes
2026-10-02 0:16 ` Karthik Nayak
2026-10-02 13:03 ` [PATCH v2] " Karthik Nayak
2026-10-05 18:34 ` Toon Claes [this message]
2026-10-06 9:36 ` Karthik Nayak
2026-10-06 9:18 ` [PATCH v3] " Karthik Nayak
2026-10-06 12:31 ` Patrick Steinhardt
2026-10-06 21:11 ` Karthik Nayak
2026-10-07 5:12 ` Patrick Steinhardt
2026-10-07 9:25 ` Karthik Nayak
2026-10-06 16:19 ` Junio C Hamano
2026-10-06 20:59 ` Karthik Nayak
2026-10-07 11:20 ` [PATCH v4] " Karthik Nayak
2026-10-07 11:52 ` Patrick Steinhardt
2026-10-08 11:41 ` Toon Claes
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=87zewsf13b.fsf@dev.null.iotcl.com.invalid \
--to=toon@iotcl.com \
--cc=git@vger.kernel.org \
--cc=karthik.188@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.