git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] reftable: pass pq_entry by address

From
Han-Wen Nienhuys <hanwen@google.com>
Date
Sep 15, 2022, 07:49 UTC
Message-ID
<CAFQ2z_P0k-VQ0mj4RQquA1SJX8RyY+63s2U2pkEr80+B8O4YXQ@mail.gmail.com>
In-Reply-To
<18338058407.117ce7158612837.8515739237320978792@elijahpepe.com>
On Tue, Sep 13, 2022 at 8:03 PM Elijah Conners <business@elijahpepe.com> wrote:
>
> Han-Wen Nienhuys <hanwen@google.com> writes:
>  > it might be a bit slower, but "dangerous"? How so?
> In this context, dangerous is the wrong word, but in some cases large objects on the stack can cause stack overflows. In this case, slower is the right word here.

I'll let you paint this bikeshed, but do note that the priority queue isn't actually optimal here, in a much bigger way. In the typical case, you'd have

1. large base reftable (created by GC)
2. small updates (created by individual ref updates)

When you're iterating, most of the iteration entries will come from the large base reftable, and only occasionally, you have to get entries from the small tables. In this scenario, the current code will insert entries from the large table into the priority queue, have it filter up to the top at cost log(number-of-tables), for each of the entries to be read.

With the current online compaction, number-of-tables = log(number-of-refs), so at log(log(number-of-refs)) it's not a huge cost, but certainly larger than the cost of copying the entry once in the function.

JGit has an optimization here where it tries to get the next entry from the table that previously provided the minimum entry. I didn't implement it for simplicity's sake, but if you care about performance, you might want to try your hand at that.

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Liana Sebastian
Previous: Elijah ConnersNext: Junio C Hamano
Message 7 of 9 in “reftable: pass pq_entry by address”
  1. reftable: pass pq_entry by addressElijah Conners, Sep 13, 2022
  2. Han-Wen NienhuysSep 13, 2022
  3. Junio C HamanoSep 13, 2022
  4. Elijah ConnersSep 13, 2022
  5. Han-Wen NienhuysSep 13, 2022
  6. Elijah ConnersSep 13, 2022
  7. Han-Wen NienhuysSep 15, 2022
  8. Junio C HamanoSep 15, 2022
  9. reftable: use const with the pq_entry paramElijah Conners, Sep 14, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.