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

Re: [PATCH v2] prio-queue: use cascade-down for faster extract-min

From
Kristofer Karlsson <krka@spotify.com>
Date
Jul 8, 2026, 12:44 UTC
Message-ID
<CAL71e4NKcCBs-UjF3ZxOGrTbT_TUAumZV_G2PAfyf4JgzCm+Cg@mail.gmail.com>
In-Reply-To
<15fa1b16-b911-47b1-a843-400e320d7e4f@web.de>
On Wed, 8 Jul 2026 at 13:55, René Scharfe <l.s.r@web.de> wrote:
Show 5 quoted lines
>
> I meant that I didn't find this optimization in other priority queue
> implementations or papers, but admittedly I didn't do an exhaustive
> search.  Given it's benefits I would have expected to find prior art
> on it pretty easily, though.

Aha! Got it, I misunderstood you first. It's actually described here[1]:

Show 7 quoted lines
> Bottom-up heapsort conceptually replaces the root with a value of −∞
> and sifts it down using only one comparison per level
> (since no child can possibly be less than −∞)
> until the leaves are reached,
> then replaces the −∞ with the correct value and sifts it up
> (again, using one comparison per level) until the correct position
> is found.

It's for heapsort, not an interactive heap, but the algorithm still matches.

Also, your idea to split out sift up/down into helper functions did work, and was quite clean - will share patch shortly once I have cleaned up the commits and benchmark data.

Thanks again, Kristofer

[1] https://en.wikipedia.org/wiki/Heapsort#Bottom-up_heapsort
Previous: René ScharfeNext: Kristofer Karlsson via GitGitGadget
Message 17 of 24 in “prio-queue: use cascade-down sift for faster extract-min”
  1. prio-queue: use cascade-down sift for faster extract-minKristofer Karlsson via GitGitGadget, May 31, 2026
  2. Junio C HamanoJun 1, 2026
  3. Junio C HamanoJun 1, 2026
  4. Kristofer KarlssonJun 1, 2026
  5. prio-queue: use cascade-down for faster extract-minKristofer Karlsson via GitGitGadget, Jun 1, 2026
  6. René ScharfeJun 2, 2026
  7. Kristofer KarlssonJun 2, 2026
  8. Kristofer KarlssonJun 5, 2026
  9. René ScharfeJun 7, 2026
  10. Kristofer KarlssonJun 7, 2026
  11. Junio C HamanoJun 29, 2026
  12. Junio C HamanoJun 8, 2026
  13. Kristofer KarlssonJul 6, 2026
  14. René ScharfeJul 8, 2026
  15. Kristofer KarlssonJul 8, 2026
  16. René ScharfeJul 8, 2026
  17. Kristofer KarlssonJul 8, 2026
  18. 0/2 prio-queue: use bottom-up sift for extract-minKristofer Karlsson via GitGitGadget, Jul 8, 2026
  19. 1/2 prio-queue: extract sift_up() from prio_queue_put()Kristofer Karlsson via GitGitGadget, Jul 8, 2026
  20. 2/2 prio-queue: use cascade for unfused getsKristofer Karlsson via GitGitGadget, Jul 8, 2026
  21. René ScharfeJul 10, 2026
  22. Kristofer KarlssonJul 10, 2026
  23. René ScharfeJul 10, 2026
  24. Kristofer KarlssonJul 10, 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.