Conversation
Assisted-By: devx/b8d3b9bd-01a3-41b1-90f8-632318b798e4
Assisted-By: devx/b8d3b9bd-01a3-41b1-90f8-632318b798e4
ianks
force-pushed
the
ianks/lazy-range-iteration
branch
from
September 16, 2026 02:43
282db86 to
cdba4e9
Compare
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.
Depends on #2118 for the existing CI repairs. This PR contains only the range implementation, regression tests, and documentation.
forandtablerowcan materialize an entire range before resource limits run. This replaces that allocation with a small integer-range window: length, offsets, and reversal use arithmetic, and values are generated as the loop visits them.Each visited range item consumes render score before entering the body, including empty bodies. Early
breakonly pays for the values visited; loop metadata andoffset:continueretain the full selected length.tablerowalso checks its generated HTML incrementally, including captured output and break paths.Tight render-score budgets may now stop range loops earlier. Output-length limits still bound bytes, not CPU work in output-free loops. Non-range collections keep the existing slicing and
load_slicebehavior.Validation and cost
All lax/strict/strict2 tests, four liquid-spec adapters, RuboCop, and the memory-profile task pass locally against the repaired baseline. Regression tests guard both historical materialization paths, so they fail safely against the old code rather than attempting huge allocations.
Five paired Ruby 4.0.6 benchmark runs measured about 2% overhead for small
forrange loops and 6% fortablerowrange loops with the additional checks. The range window stayed at 80 bytes for cardinalities of 10, one million, and one billion; output storage is separate.