Repository navigation
Build rows lazily: walk and neighbours (M11) - #66
Merged
Merged
Conversation
walk built every row's external ids as the walk ran, and neighbours built a node's neighbours' ids inside a closure over the loaded version, both in the call's multi-call memory context, held until the call ended. walk now keeps warren_core's walk result (the ends' dense ids, or each path's nodes and relations) in its reserved buffers and neighbours collects the node's distinct neighbours as dense ids (Adjacency::collect_neighbours); each returns an iterator holding the loaded version that makes a row's ids, path array and relation names in next(). A pg_test for each opens a cursor on a call over a star of 50,000 or 1,000 IRI leaves and checks what it holds after its first row does not grow with the rows to come: 3.7 MB (neighbours, walk ends) and 17.9 MB (walk paths) more for 50,000 before, 34 KB after. shared_cache_lazy_rows.sql covers both under LIMIT, in cursors read after warren.evict, and erroring or cancelled mid-scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Rxfe2L3iVjSwSBPdUu1Ke
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This finishes the lazy-rows work from #63.
warren.walkandwarren.neighboursnow build each row's external ids innext(), in the per-row context, instead of up front in the multi-call context.walk:traversal::walk. Its result (end dense ids, or each path's nodes and relations) stays in warren-core'stry_reserved buffers, bounded bymax_resultsandwarren.max_walk_pathsas before.next()builds the end id, the path array and the relation names. It reads only the type cache: no SPI,search_pathor identity switch.neighbours:Adjacency::collect_neighbourscollects one node's distinct neighbours as dense ids into a buffer reserved up front: 8 B per neighbour, bounded by the node's degree. Before, about 72 B per text id was held.Arc<LoadedVersion>.Memory held after the first row, 50,000 vs 1,000 rows (TDD: these tests fail on main):
neighbourswalkendswalkpathstest/sql/shared_cache_lazy_rows.sqlnow covers both functions in all three cache modes:LIMIT, cursors read across statements afterwarren.evict, an error at row 5,000, and a cancel between rows. DESIGN §12 and §13 are updated.Gate:
run.pyPG16, all three modes: 62/62.dump.py: ok.Generated by Claude Code