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

Re: [PATCH] prio-queue: fold lazy_queue into prio_queue for automatic get+put fusion

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 6, 2026, 16:31 UTC
Message-ID
<xmqqqzmjbpfp.fsf@gitster.g>
In-Reply-To
<pull.2140.git.1780757885582.gitgitgadget@gmail.com>

"Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Add prio_queue_size() for callers that need the logical element
> count, since the physical nr may temporarily include a
> pending-removal element.

Many code paths used to learn how many elements it logically has by directly peeking into .nr member of the prio_queue struct. Now they should call this new helper function, and you converted some in this patch.

How can we be sure that all such users of prio_queue has been converted? Are direct references to .nr member, outside of the prio-queue.c implementation, all now suspect?

For example, object-name.c:get_oid_oneline() uses a prio-queue "copy", and loops "while (copy.nr)". In the loop, it calls pop_most_recent_commit(), which does a get followed by put of its parents. If the get become hanging (e.g., root commit, causing no _put() performed in pop_most_recent_commit()), would copy.nr still remain 1 but logically no elements remain in the queue.

There seem to be other direct peeking of .nr member remaining in the code. Perhaps the member should be renamed to catch in-flight topics that add more users of prio-queue that peek into the .nr member, or something like that.

Previous: Kristofer Karlsson via GitGitGadgetNext: Kristofer Karlsson
Message 2 of 18 in “prio-queue: fold lazy_queue into prio_queue for automatic get+put fusion”
  1. prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 6, 2026
  2. Junio C HamanoJun 6, 2026
  3. Kristofer KarlssonJun 6, 2026
  4. Junio C HamanoJun 8, 2026
  5. 0/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 6, 2026
  6. 1/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 6, 2026
  7. 2/2 prio-queue: rename .nr to .nr_internal to prevent direct accessKristofer Karlsson via GitGitGadget, Jun 6, 2026
  8. René ScharfeJun 7, 2026
  9. Kristofer KarlssonJun 7, 2026
  10. 0/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 7, 2026
  11. 1/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 7, 2026
  12. 2/2 prio-queue: rename .nr to .nr_internal to prevent direct accessKristofer Karlsson via GitGitGadget, Jun 7, 2026
  13. Junio C HamanoJun 8, 2026
  14. 0/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 8, 2026
  15. 1/2 prio-queue: rename .nr to .nr_ and add accessor helpersKristofer Karlsson via GitGitGadget, Jun 8, 2026
  16. 2/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 8, 2026
  17. Junio C HamanoJun 30, 2026
  18. Kristofer KarlssonJun 30, 2026

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.