Repository navigation
MOD-19160 Json Path perf improvements - #1661
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1661 +/- ##
==========================================
+ Coverage 88.06% 88.13% +0.06%
==========================================
Files 17 17
Lines 5957 6049 +92
==========================================
+ Hits 5246 5331 +85
- Misses 711 718 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
TalBarYakar
reviewed
Oct 4, 2026
| ); | ||
| let result = Self::results_to_term(new_calc_data.results); | ||
| if let Some(cache) = &mut calc_data.root_cache { | ||
| cache.insert(key, result.clone()); |
Contributor
There was a problem hiding this comment.
Can we limit the cache size or skip large results? Repeated $ paths keep separate result lists in memory, which can add up quickly.
TalBarYakar
approved these changes
Oct 4, 2026
4 tasks
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.
Optimize JSONPath parsing and evaluation by reducing repeated work and allocations.
$.a[[email protected][[email protected]]].$..uid.$.rows[[email protected] > $.threshold], resolve$.thresholdonce. Enable caching only for multi-candidate filters.$.rows[[email protected]], finding oneflagavoids searching the remaining descendants.Observed locally against master, across three paired runs on 13 workloads:
$.rows[0].score; ~56% for the root-comparison filter.Measured before/after path evaluation time, using medians across three local Criterion runs. Compilation, Redis command handling, and response serialization are excluded.
First two commands use this document: 256 rows and 128 limits. Comments mark omitted entries.
Existence query (
$.rows[[email protected]].uid) uses 128 rows, each containing a 341-object subtree:Root caching avoids repeated traversal across candidates. Existence filters stop at the first match, making the largest gain dependent on match position
Note
Medium Risk
Changes core JSONPath parsing and filter evaluation semantics with broad benchmark coverage, but behavior is heavily regression-tested; CI workflow changes affect gating timing, not runtime query results.
Overview
This PR speeds up JSONPath compilation and evaluation and reworks how CI compares performance against master.
Evaluator and grammar: Nested filters compile with less parser backtracking via a factored
method_chainand explicit parenthesized filter parsing ([?(@.x > 1)]). Evaluation avoids extra allocations when walking borrowed objects, returns the internal result buffer directly, compares strings via borrowedas_str, and splits regex caching into lazy search vs full-match maps. Multi-candidate filters cache repeated$…operands and existence checks stop at the first match; caches stay off for single-row filters and cap large root lists.Benchmarks and CI: The Criterion suite grows to 81 workloads (grouped filters, root/existence cases, etc.) and writes each workload’s JSONPath to
paths.jsonlfor reports. The JSONPath job drops cached cross-run baselines, checks out master and the PR on the same runner, intersects benchmark names, remeasures flagged ≥5% slowdowns on both revisions, and emits a markdown job summary (tables, status, optional JSONPath column) viajsonpath_benchmark_gate.py --summary. Partial workload overlap is allowed; new names show “No master baseline” instead of failing the compare step.Reviewed by Cursor Bugbot for commit 1088990. Bugbot is set up for automated code reviews on this repo. Configure here.