git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/7] reftable/merged: skip comparison for records of the same subiter
Date: Thu, 1 Feb 2024 12:29:16 -0500	[thread overview]
Message-ID: <CAPig+cQwgYdKCHnu1TUj2JYyQkRF6Ey4hw1MvAVpfhqcwjV04w@mail.gmail.com> (raw)
In-Reply-To: <0ca86eba710895f0e22fc15fe5221f5487031f64.1706782841.git.ps@pks.im>

On Thu, Feb 1, 2024 at 8:17 AM Patrick Steinhardt <ps@pks.im> wrote:
> When retrieving the next entry of a merged iterator we need to drop all
> records of other sub-iterators that would be shadowed by the record that
> we are about to return. We do this by comparing record keys, dropping
> all keys that are smaller or equal to the key of the record we are about
> to return.
>
> There is an edge case here where we can skip that comparison: when the
> record in the priority queue comes from the same subiterator than the

s/than/as/

> record we are about to return then we know that its key must be larger
> than the key of the record we are about to return. This property is
> guaranteed by the sub-iterators, and if it didn't hold then the whole
> merged iterator would return records in the wrong order, too.
>
> While this may seem like a very specific edge case it's in fact quite
> likely to happen. For most repositories out there you can assume that we
> will end up with one large table and several smaller ones on top of it.
> Thus, it is very likely that the next entry will sort towards the top of
> the priority queue.
>
> Special case this and break out of the loop in that case. The following
> benchmark uses git-show-ref(1) to print a single ref matching a pattern
> out of 1 million refs:
>
>   Benchmark 1: show-ref: single matching ref (revision = HEAD~)
>     Time (mean ± σ):     162.6 ms ±   4.5 ms    [User: 159.0 ms, System: 3.5 ms]
>     Range (min … max):   156.6 ms … 188.5 ms    1000 runs
>
>   Benchmark 2: show-ref: single matching ref (revision = HEAD)
>     Time (mean ± σ):     156.8 ms ±   4.7 ms    [User: 153.0 ms, System: 3.6 ms]
>     Range (min … max):   151.4 ms … 188.4 ms    1000 runs
>
>   Summary
>     show-ref: single matching ref (revision = HEAD) ran
>       1.04 ± 0.04 times faster than show-ref: single matching ref (revision = HEAD~)
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>

  reply	other threads:[~2024-02-01 17:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 10:24 [PATCH 0/7] reftable: improve ref iteration performance Patrick Steinhardt
2024-02-01 10:24 ` [PATCH 1/7] reftable/record: introduce function to compare records by key Patrick Steinhardt
2024-02-01 15:00   ` Eric Sunshine
2024-02-01 10:25 ` [PATCH 2/7] reftable/merged: allocation-less dropping of shadowed records Patrick Steinhardt
2024-02-01 10:25 ` [PATCH 3/7] reftable/merged: skip comparison for records of the same subiter Patrick Steinhardt
2024-02-01 17:29   ` Eric Sunshine [this message]
2024-02-02  5:15     ` Patrick Steinhardt
2024-02-01 10:25 ` [PATCH 4/7] reftable/pq: allocation-less comparison of entry keys Patrick Steinhardt
2024-02-01 10:25 ` [PATCH 5/7] reftable/block: swap buffers instead of copying Patrick Steinhardt
2024-02-01 10:25 ` [PATCH 6/7] reftable/record: don't try to reallocate ref record name Patrick Steinhardt
2024-02-01 10:25 ` [PATCH 7/7] reftable/reader: add comments to `table_iter_next()` Patrick Steinhardt
2024-02-09 16:01   ` John Cai
2024-02-12  8:24     ` Patrick Steinhardt
2024-02-12  8:32 ` [PATCH v2 0/7] reftable: improve ref iteration performance Patrick Steinhardt
2024-02-12  8:32   ` [PATCH v2 1/7] reftable/record: introduce function to compare records by key Patrick Steinhardt
2024-02-12  8:32   ` [PATCH v2 2/7] reftable/merged: allocation-less dropping of shadowed records Patrick Steinhardt
2024-02-12  8:32   ` [PATCH v2 3/7] reftable/merged: skip comparison for records of the same subiter Patrick Steinhardt
2024-02-12  8:32   ` [PATCH v2 4/7] reftable/pq: allocation-less comparison of entry keys Patrick Steinhardt
2024-02-12  8:32   ` [PATCH v2 5/7] reftable/block: swap buffers instead of copying Patrick Steinhardt
2024-02-12  8:32   ` [PATCH v2 6/7] reftable/record: don't try to reallocate ref record name Patrick Steinhardt
2024-02-12  8:32   ` [PATCH v2 7/7] reftable/reader: add comments to `table_iter_next()` Patrick Steinhardt
2024-02-12 17:19     ` Junio C Hamano
2024-02-13  6:57       ` Patrick Steinhardt

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=CAPig+cQwgYdKCHnu1TUj2JYyQkRF6Ey4hw1MvAVpfhqcwjV04w@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    /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).