Skip to content

test(jq): pin recurse/.. partial-error behavior and add depth-scaling benchmark - #662

Merged
newhoggy merged 3 commits into
mainfrom
issue-661-recurse-partial-error-bench
Aug 8, 2026
Merged

test(jq): pin recurse/.. partial-error behavior and add depth-scaling benchmark#662
newhoggy merged 3 commits into
mainfrom
issue-661-recurse-partial-error-bench

Conversation

@newhoggy

@newhoggy newhoggy commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

De-risk step for #626 (proposed Cow<'a, OwnedValue> refactor of push_recursive_branches/resolve_recurse in src/jq/eval.rs, to eliminate an O(subtree)-per-node clone). Test/bench-only — no production code changes.

Test plan

  • ./scripts/sync-jq-golden.sh --check — 331 goldens up to date, no drift
  • cargo test --features cli --test jq_golden_tests — new cases pass, known-failures manifest unchanged
  • cargo test --test jq_recurse_depth_tests — 3/3 pass
  • cargo bench --bench jq_recurse_depth_bench -- --quick — runs clean, reproduces perf(jq): eval_index_expr/eval_slice_bound eagerly materialize a computed key/bound's full subtree before checking whether it's usable #626's O(depth²) signature
  • cargo clippy --all-targets --all-features -- -D warnings and the std,simd,serde,cli,regex,bench-runner,large-tests,mmap-tests feature-set variant — clean
  • cargo test --features cli (full suite) — clean
  • git diff --stat -- src/jq/eval.rs — empty, per this issue's explicit constraint

Closes #661

Every existing recurse/`..` golden fixture wraps its filter in `[...]`,
which collapses `QueryResult::Partial` back to a bare `Error` before it
reaches stdout — so nothing exercises what `resolve_recurse`'s
`Err((outputs, e))` early-return actually streams.

Adds two cases, unwrapped so the prefix streams:
- path_recurse_cond_error_after_output: resolve_recurse's parameterized
  recurse(f;cond) path
- path_recursive_descent_error_after_output: push_recursive_branches'
  bare `..` path, with the error triggered by a later pipe stage

Captured via ./scripts/sync-jq-golden.sh against the pinned jq oracle;
succinctly matches jq byte-for-byte on both, including stderr's
`<stdin>:0` line-number quirk.

De-risk step for #626 (Cow<'a, OwnedValue> refactor of these two
functions).

Refs #661
No recurse/`..` fixture nests past 3 levels, so nothing would catch a
depth-dependent correctness bug — e.g. a lifetime that only breaks past
a few stack frames in #626's proposed Cow<'a, OwnedValue> rewrite of
push_recursive_branches/resolve_recurse.

Drives path(..), path(recurse), and path(recurse(.k; cond)) — covering
both functions #626 touches — against a 300-level linear-nesting
document, asserting the exact, independently-derived path set. Depth
300 is deliberately beyond what real jq's own parser accepts on this
shape (~128), so this is a pure internal correctness pin, not an
oracle comparison.

Refs #661
No checked-in benchmark reproduces #626's synthetic linear-nesting
document and scaling table, so "the fix worked" would have to be
eyeballed rather than measured against a baseline.

Adds an in-process Criterion bench (not a CLI-spawn A/B — these
depth-100-to-400 documents are far below the >=1MB floor the A/B
method's process-spawn rule needs) reproducing #626's document —
{"k": {"k": ... "pad": {"a":{},"b":{},"c":{}}}} — and query,
.. | .[.k]?, at #626's own depths (100/200/300/400) so a before/after
run of that fix is directly comparable to its table. A smoke run
already reproduces the O(depth^2) signature #626 describes. Makes no
timing assertion itself.

Closes #661
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Coverage

Total: 84.12% 🟢 0 pp vs main

Comparing 204b08b..13d5848 (merge-base → PR head)

No per-file coverage changes vs main.

Patch coverage

No new executable lines added by this diff.

📦 Full per-file coverage summary · run summary

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Coverage

Total: 84.03% 🟢 0 pp vs main

Comparing 204b08b..13d5848 (merge-base → PR head)

No per-file coverage changes vs main.

Patch coverage

No new executable lines added by this diff.

📦 Full per-file coverage summary · run summary

@newhoggy
newhoggy merged commit cf15aee into main Aug 8, 2026
27 checks passed
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.

test(jq): pin recurse/'..' partial-output-before-error behavior and add a depth-scaling benchmark ahead of #626

1 participant