Skip to content

Share decoded blocks between callers inflating the same node - #105

Open
mafintosh wants to merge 1 commit into
mainfrom
inflation
Open

mafintosh wants to merge 1 commit into
mainfrom
inflation

Conversation

@mafintosh

Copy link
Copy Markdown
Contributor

Every caller runs the inflation IO under its own config, so timeout, wait and cancellation are per caller and hypercore dedups the fetches. Decoded blocks land in slots on ptr.inflating shared by all callers, so the first to wake decodes and a late caller only fetches what is still missing.

@mafintosh
mafintosh requested a review from a team October 15, 2026 00:06
Every caller runs the inflation IO under its own config, so timeout, wait
and cancellation are per caller and hypercore dedups the fetches. Decoded
blocks land in slots on ptr.inflating shared by all callers, so the first
to wake decodes and a late caller only fetches what is still missing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@caolan-tether

Copy link
Copy Markdown

This risks parallel walks of the tree to inflate the node but most the actual work is shared so the cost should be minimal. It also respects the 'wait' option that is difficult to handle with a simple lock as proposed in #94. Seems like a good idea to me.

@mafintosh
mafintosh requested a review from a team October 20, 2026 12:05
@caolan-tether

Copy link
Copy Markdown

I ran this through hyperbee-benchmarks with no noticeable change in performance.

@caolan-tether

Copy link
Copy Markdown

I also ran this with a large database and tested memory usage. It is comparable to main (while fixing some edge cases). I tested pre-shared-inflate code too and observed the difference in memory usage. It seems to continue to address the OOM case the original inflate sharing code was written for.

@caolan-tether caolan-tether left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I believe @lejeunerenard also wants to take a look before merging.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants