docs(jq,yq): record getpath slice's alias cost as an accepted gap - #3141
Merged
Merged
Conversation
newhoggy
force-pushed
the
issue-2641-getpath-slice-alias-amp
branch
from
September 18, 2026 05:52
e30f8e0 to
8b47df7
Compare
CoverageTotal: 94% ⚪ 0 pp vs Comparing No per-file coverage changes vs 🔇 0 ignored region(s), 166 tolerated region(s)
Patch coverageNo new executable lines added by this diff. |
CoverageTotal: 93.91% ⚪ 0 pp vs Comparing No per-file coverage changes vs 🔇 0 ignored region(s), 167 tolerated region(s)
Patch coverageNo new executable lines added by this diff. |
) getpath(["items", {slice}])'s array fast path (getpath_walk_cursor, src/jq/eval_generic.rs) is O(2^N) on #1804's alias fan-out shape when the sliced range contains the aliased element, because it materializes the element's expanded value the same way to_owned_cursor always has -- #1804's is_alias() short-circuit is a validation-walk property (only needs to know a node exists) and cannot transfer to a walk that has to build the value itself. Every other value-producing route pays the identical cost (eval_slice_expr, array construction), so this is inherent to the copy model, not a bug in this arm. Records the rule and the measured cost in docs/compliance/yq/limitations.md's #1804/#2476/#2173 history block, notes it at the slice arm itself, and pins the two cases that do stay flat (out-of-range slice, navigated index) as timing-guard tests so a future regression back to O(2^N) on those shapes is caught. Fixes #2641
newhoggy
force-pushed
the
issue-2641-getpath-slice-alias-amp
branch
from
September 18, 2026 06:25
8b47df7 to
9db90e2
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.
Summary
getpath(["items", {slice}])'s array fast path (getpath_walk_cursor,src/jq/eval_generic.rs) isO(2^N)on yaml: unmemoized alias resolution inside as_object/as_array can amplify a deeply-aliased document exponentially #1804's alias fan-out shape (aN: &aN [*a(N-1), *a(N-1)]) when the sliced range contains the aliased element, because it materializes the element's expanded value viato_owned_cursor— the same copy-model cost every value-producing read of an aliased node pays.is_alias()short-circuit is a validation-walk property (only needs to know a node exists, never what it contains) and cannot transfer to a walk that has to build the value itself — confirmed by re-deriving the exponential curve live (0.02s/0.06s/0.24s/0.96s at N=14/16/18/20, matching yaml: unmemoized alias resolution inside as_object/as_array can amplify a deeply-aliased document exponentially #1804's own×2-per-level signature) and confirming both flat controls (out-of-range slice, navigated index) stay at 0.00s through N=30.docs/compliance/yq/limitations.md's existing yaml: unmemoized alias resolution inside as_object/as_array can amplify a deeply-aliased document exponentially #1804/yaml/jq: and/or/not////any remain O(2^N) over an alias fan-out; #1804's fix does not reach them #2476/jq: eval_generic's_bridge materializes the whole document for filters that read nothing (1+1: 443 MB peak on a 16 MB file) #2173 history block, with a pointer comment at the slice arm itself and two new timing-guard tests pinning the flat cases so a regression back toO(2^N)on those shapes is caught.Test plan
cargo build --features clicargo test --features cli,simd,regex,serde(full suite: 8950 passed, 0 failed)cargo clippy --all-targets --all-features -- -D warningscargo clippy --all-targets --features std,simd,serde,cli,regex,bench-runner,large-tests,mmap-tests -- -D warningscargo llvm-cov --features cli,simd,regex,serde --workspace --summary-onlyFixes #2641