Repository navigation
perf(folsom): avoid copying ASCII response tokens - #247
Open
petedmarsh wants to merge 4 commits into
Open
petedmarsh wants to merge 4 commits into
petedmarsh wants to merge 4 commits into
Conversation
Co-Authored-By: Codex <noreply@openai.com>
JMH 1.37, JDK 25.0.1, arm64 Docker Desktop (18 available CPUs), -XX:ActiveProcessorCount=32. One thread, two forks, 4x1s warmup and 5x1s measurement per fork; -prof gc. The benchmark reuses its decoder, ByteBuf and output list, measuring direct decode of 64-byte values without socket or scheduling costs. Baseline (mean ns/op +/- JMH 99.9% error; allocated B/op): single hit 120.037 +/- 41.132, 400.001; batch of 16 hits 1386.719 +/- 31.427, 2440.010; miss 15.109 +/- 0.147, approximately zero. One noisy 197 ns single-hit iteration inflated that mean; the batch result is the more stable comparison. Co-Authored-By: Codex <noreply@openai.com>
Parse tokens as offsets into the existing response-line buffer instead of copying each token into a second ByteBuffer. Keep key and value ownership unchanged. Decoder and adjacent ASCII request tests pass; formatting check passes. Clean A/B JMH rerun (JDK 25.0.1, arm64 Docker, ActiveProcessorCount=32, 2 forks, 4x1s warmup, 5x1s measurement, gc profiler): single 64-byte hit 110.483 +/- 0.663 ns/op baseline versus 74.805 +/- 0.567 and 76.021 +/- 0.584 ns/op in two changed-code runs (about 31-32% lower). Batch of 16 hits 1370.720 +/- 20.757 ns/op baseline versus 1329.864 +/- 7.220 and 1344.472 +/- 34.787 ns/op (about 2-3% lower; small enough to be sensitive to run noise). Allocation is unchanged: 400 B/single hit and 2440 B/batch16. The benchmark isolates decode, not end-to-end client CPU. Co-Authored-By: Codex <noreply@openai.com>
Keep the baseline and before/after JMH results in the preceding commit messages while leaving the production branch with only decoder tests and the measured optimization. Focused decoder and adjacent ASCII request tests and fmt:check pass after removal. Co-Authored-By: Codex <noreply@openai.com>
MK-Lau
approved these changes
Sep 25, 2026
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.
Parse ASCII response tokens as offsets into the existing line buffer instead of copying each token into a second buffer. Add tests for multi-value, fragmented, UTF-8 stats, and scalar responses.
Benchmark
Decoder-only JMH 1.37 on JDK 25.0.1 with
ActiveProcessorCount=32. Times are mean +/- JMH 99.9% error.