Repository navigation
Use the native ijson writer for compact whole-document JSON.GET - #1734
Open
fcostaoliveira wants to merge 4 commits into
Open
fcostaoliveira wants to merge 4 commits into
fcostaoliveira wants to merge 4 commits into
Conversation
fcostaoliveira
marked this pull request as ready for review
December 3, 2026 16:24
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1734 +/- ##
==========================================
+ Coverage 88.48% 88.53% +0.05%
==========================================
Files 18 18
Lines 7026 7040 +14
==========================================
+ Hits 6217 6233 +16
+ Misses 809 807 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
@AvivDavid23 please check 🙏 |
This branch has not been deployed
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.
Use the compact JSON writer from RedisJSON/ijson#34 for whole-document string replies. A legacy root GET (no path or
.) writes the document into the Redis reply buffer. A single$returns the same document inside a one-element JSON array. Both shapes can read the stored root directly. Formatted replies, other paths, JSON.PATH, JSON.MGET and expanded RESP3 replies continue through their existing handling.The ijson update from
379dadfto8489133includes the benchmark suite (#29), one-probe removal of interned strings (#31), inline string handle construction (#33), and the native writer (#34). The two string changes also run on writes. ijson comparisonThe default implementation for other JSON value backends delegates to serde_json.
Current revision
The branch includes RedisJSON master
ba051ddf, which contains the newly merged static-path scanner. PR head60811c00adds regression coverage for a string escape past the first word, an unsigned integer abovei64::MAX, a typed FP16 array, and the default RESP3 compact root reply. The two targeted live-server tests and all 458 Rust tests and doctests passed locally. The previous timing and review results below identify the pre-scanner revisions they compared. The Graviton4 results below use this new master. The new Fable review is in progress. Current CIThe current x86-64 Callgrind comparison measured 83 workloads. The largest instruction-count increase was 0.49% (
eval/projection-keys). The five-fixture memory job found equal total key bytes in every case. The medium fixture used 64 B more process dataset RAM and the repeated-string replacement SET took 5.33% more server time. In six dedicated AMD pairs using the same Rust 1.100.0 compiler, the repeated-string SET cost was +1.05%. The medium fixture’s median process RAM difference was +64 B for master/PR and also +64 B for master against a copy of itself. An independent 20-pair rerun measured a master/PR median of 0 B. In all 80 processes across that rerun and its 20 A/A pairs, total key memory was 62,520 B, allocated dataset bytes grew by 66,000 B, and the remaining process variation matched the main Redis keyspace hash-table overhead byte-for-byte. Instruction counts · Memory and SET comparisonAn independent Rust test also exercised the public default writer on
serde_json::Value. For null, booleans, a maximum-width unsigned integer, escaped strings, Unicode and nested values, it kept a nonempty output prefix and appended exactly the bytes fromserde_json::to_vec. The shipped RedisJSON backend exercises the ijson override. On arm64, the review measured a 144 B stack frame per nested object (96 B on master) and 208 B per nested array (224 B on master). At the enforced 128-level limit, an all-object chain uses about 6 KiB more stack.Current command benchmark checks
All 51 hosted command workloads completed on master
ba051ddfand PR60811c00. Four lost more than 3% throughput in CI (GeoJSON ARRAPPEND, deep-path SET, integer-array SET and scalar SET). The table shows completed rechecks on dedicated AMD hardware. Each used the hosted run’s unmodified server, client, modules and workload files, with four alternating master/PR pairs. The module and tool hashes matched before and after each series. Percentages use median paired throughput change. The two SET guards from the previous review are still running on a separate dedicated host. Hosted command comparisonjson_arrappend_geojsonjson_set_auto_create_deep_pathsjson_set_homogeneous_integer_arraysjson_set_sclr_pass_100_jsonPaired master and PR rates on the dedicated host (requests/s)
json_arrappend_geojsonjson_set_auto_create_deep_pathsjson_set_homogeneous_integer_arraysjson_set_sclr_pass_100_jsonA separate dedicated AMD comparison repeated the six balanced blocks that had identified the places SET regression on the previous revision. Each block used master, master with only the ijson dependency update, and the complete PR. Their median rates were 3,566, 3,630 and 3,767 requests/s. The PR gained 5.64% against master within blocks (+7.53%, +3.73%, +5.67%, +5.62%, −0.04%, +7.53%) and 3.78% against the dependency-only build. The dependency update alone gained 1.78% against master. This used release builds with rustc 1.92.0, 10,000 preloaded keys and 50,000 overwrites in each of 18 cells. All 900,000 overwrites succeeded, every sampled readback matched and each sampled key used 89,556 B. The median paired PR change was 0 B for dataset RAM, −440 B retained and −376 B peak for the overall process.
Current Graviton4 end-to-end throughput
Direct client rates on master
ba051ddf(includes the static-path scanner) and PR60811c00. Redis 8.12.0, rustc 1.92.0 release with default flags, one pinned Neoverse-V2 server core, two separate client cores, 16 connections, pipeline 1. Each rate is the median of three interleaved rounds. Percentages use the median change within pairs.JSON.GET key $JSON.GET keyJSON.GET key $JSON.GET keyJSON.GET key $.nEach sample completed 500,000, 1,000,000 or 4,000,000 requests for Yelp, Yahoo2 or the control respectively, after 5,000 warm-up requests. The client timer has 250 ms resolution. Median server CPU per
JSON.GET key $was 37.84 → 26.32 µs on Yelp and 20.76 → 14.91 µs on Yahoo2. The host exposed 96 physical cores with no SMT or readable CPU-frequency controls. A separate parity run returned 935 byte-identical replies and 17 equivalent expanded replies across RESP2 and RESP3.Document bytes were identical on every trial (42,400 B Yelp, 19,544 B Yahoo2, 32 B control). Median end-of-run used memory was 1,175,544 → 1,175,504 B. The median Redis process high-water mark was 1,816,056 → 1,840,400 B (+24,344 B), with a higher PR peak in two of the three rounds.
A second Graviton4 ran the identical modules with a fresh build of the same Redis 8.12.0 tag and allocator. Two identical master binaries reproduced the roughly 24 KB step in either direction. Repeating the original full 500,000-request Yelp row across four PR/master pairs gave a median process peak change of −32 B and median retained change of −8 B. Four master/master control pairs on that same row included a +24,400 B peak difference. Six master/PR pairs with the same queued replies had a median peak change of −32 B (range −40 to −24 B), versus 0 B for six master/master pairs. In a separate instrumented server, the candidate’s peak for each GET was equal to master’s or 16 B lower across 76 matched states and 3,840 GETs. In that reproduction, the process peak depended on queued reply buffers and when Redis sampled its allocator. The first throughput run did not record which allocation produced its high-water mark.
A separate process-scoped topdown-profiler capture of Yelp compact root GET on the same binaries recorded five 1-second intervals per side. Mean L1 slot shares, master → PR, were Frontend Bound 22.2% → 19.7%, Bad Speculation 2.7% → 2.5%, Backend Bound 26.3% → 25.9%, and Retiring 48.8% → 52.0% (rounding to 0.1%). Matched symbolized CPU profiles were saved locally. The latest revision has the following platform coverage.
Earlier revision, before the static-path scanner merged
Correctness on
ae5c7cdd451 Rust tests passed locally in the default configuration, single-threaded, and the release module built.
The new command-level test passed against a live server. A separate comparison with RedisJSON master
693e4c35on the same server binary returned 935 byte-identical RESP2/RESP3 replies over 17 documents, plus 17 equal RESP3 expanded replies with map order ignored. Cases included escaped text, typed arrays, missing keys, errors, formatting and projection-independent commands.The optional all-features run on macOS reproduced two failures on both master and this branch.
test_get_memorysaw 864 versus the expected 480 bytes on both. The following shared-string test failed on the poisoned lock.On
ae5c7cdd, the unchanged Gungraun/Callgrind check reports zero regressions across all 83 workloads.$.numbers.append(64)now takes exactly 22,478 instructions on both master and the PR, after making the JSON null fallback lazy during array element conversion. CI benchmarkThe remote Fable 5.2 xhigh review found no correctness blocker on
ae5c7cddbut required both SET reruns to clear 3% before merge. The places SET missed that condition. On arm64, the review passed 453 Rust tests and 322 shipped pytest cases. It compared 694,363 replies against master over 6,184 documents. Every reply matched byte-for-byte or differed only in unordered map key order.Command and memory checks on
ae5c7cddOn the same master and PR revisions, all 51 x86-64 command benchmarks completed. Full-document Yelp GET measured 11,350 → 16,117 req/s (+41.45%), and Yahoo2 GET measured 38,271 → 56,732 req/s (+48.28%). Percentages use the CI driver’s paired changes where it collected multiple attempts. Two SET workloads crossed 3% slower in the hosted run. The full-document places fixture fell 3.36%, and Yelp’s nested
message.codeSET fell 3.34%. Four dedicated AMD pairs using the same CI modules, client, server and workload files measured +0.84% on Yelp’s nested SET and −3.65% on the full-document places SET (individual changes −4.96%, −2.95%, −3.08%, −4.22%). That result blocked the pre-scanner revision. The same workloads are running on the refreshed branch. Command benchmark reportA separate AMD comparison on the pre-scanner base used six balanced blocks of 50,000 full-document SETs apiece after loading 10,000 keys. Median throughput was 3,629 req/s on master, 3,696 req/s on master with only the ijson dependency update, and 3,442 req/s on
ae5c7cdd. The PR was 5.16% slower than master and 6.88% slower than the dependency-only build using the median within-block change. Every cell had the same key count and readback hash. This confirms a slowdown on that revision and fixture. Its cause is still open, and the refreshed PR needs the same check against masterba051ddf.The memory comparison reported equal total key bytes for all five fixtures. Dataset RAM (used memory after load minus the empty-process baseline) was equal or lower on the PR for every fixture. Memory comparison
Graviton4 throughput before the scanner merged
Direct client measurements against RedisJSON master
693e4c35and PR headae5c7cdd. Rates are median completed requests per second over three paired rounds. The percentage is the median of the three within-round changes.JSON.GET key $JSON.GET key $JSON.GET keyJSON.GET keyJSON.GET key $.nOne dedicated arm64 Neoverse-V2 host, Redis server and redis-benchmark 8.12.0, Rust 1.92.0 release builds. The server used one pinned core and the two client threads used two other pinned cores on loopback. Each workload used 16 clients, pipeline depth 1, and 5,000 warm-up requests per sample. Each measured sample sent 500,000 requests per Yelp command, 1,000,000 per Yahoo2 command and 4,000,000 for the control. Master and PR alternated first across rounds. All read commands completed without errors. The host exposed no CPU-frequency governor reading. Intel, AMD and Apple throughput were outside this Graviton4 run.
The machine exposed 96 Neoverse-V2 cores with one thread per core. Both modules used rustc 1.92.0 in release mode with no additional Rust compiler flags. The client's 250 ms completion check corresponds to about 1.3–1.9% of a target-row sample, which explains several equal rounded rates. The median server CPU time per completed
JSON.GET key $was 38.74 → 26.24 µs on Yelp and 21.73 → 14.87 µs on Yahoo2. The control was 5.40 → 5.39 µs.RedisJSON reported identical document sizes in every round (42,400 B for Yelp, 19,544 B for Yahoo2 and 32 B for the control). Median end-of-run Redis
used_memorywas 1,175,520 B on master and 1,175,512 B on the PR. Medianused_memory_peakwas 1,816,112 B and 1,816,008 B respectively.The same-host RESP2/RESP3 comparison against master also passed on both the pin-only build and the PR, with 935 byte-identical replies and 17 equivalent expanded replies per comparison.
Individual rounds and dependency-only comparison
JSON.GET key $JSON.GET key $JSON.GET keyJSON.GET keyJSON.GET key $.nA separate six-round comparison exercised every ordering of master, master with only the ijson dependency update, and the earlier writer commit
38e454a7, with 100,000 requests per workload. The shorter runs give coarser estimates because redis-benchmark checks completion on a 250 ms timer. Redis benchmark clientJSON.GET key $JSON.GET key $JSON.GET keyJSON.GET keyJSON.GET key $.n