Repository navigation
Conversation
Signed-off-by: Guy Korland <gkorland@gmail.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Guy Korland <gkorland@gmail.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 40 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the mutation-ordering optimization.
No open issues 🎉
What changed in this PR
Optimizes mutation ordering by computing each JSON Pointer path’s depth once, preserving deepest-first ordering and stable ordering for equal-depth paths.
Changes:
- Replaces repeated path scans during sorting with cached depths.
- Returns early for empty and singleton result sets, avoiding depth allocation and scanning.
- Adds unit tests for ordering, tie stability, escaped tokens, and empty and singleton results.
| File | Description |
|---|---|
tst/unit/dom_test.cc |
Adds focused tests for mutation ordering and edge cases. |
src/json/dom.cc |
Caches path depths before sorting and adds an empty/singleton fast path. |
Review effort: Balanced
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.
Mutation ordering in
order_result_set_deepest_firstpreviously rescanned each JSON Pointer path withstd::count(..., '/')on everystd::stable_sortcomparison, doing repeated O(path length) work across O(N log N) comparisons.Precompute each path's
'/'depth once before sorting while preserving stable deepest-first ordering for equal depths, and return early whenrs.size() <= 1to avoid allocating a depth vector or scanning the path on empty and singleton result sets. Unit tests cover deepest-first ordering, equal-depth tie stability, escaped path tokens, empty results, and root/nested singletons.Local benchmark: Paired nine-round Release (
-O3 -DNDEBUG) measurements on arm64 comparingunstableagainst this change:order_result_set(N=1)order_result_set(N=16)order_result_set(N=256)order_result_set(N=2048)dom_clear("$..items")(341 matches)Timings are local microbenchmarks; actual gains may vary by workload and environment.