Repository navigation
perf(miss-tracking): drop reply materialization for EmptyCollection arbitrary commands [RED-200840] - #469
Merged
fcostaoliveira merged 1 commit intoJun 16, 2026
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
…rbitrary commands
Arbitrary-command miss-tracking (auto, default-on since v2.4.x) forced
set_keep_value(true) for EmptyCollection-shaped replies (HGETALL, SMEMBERS,
LRANGE, ...). That makes the protocol parser malloc + memcpy every element of
every reply just to later check whether the top-level array was empty, costing
5-11% throughput on the hash datapath nightly (RED-200840).
EmptyCollection only needs to know whether the reply's top-level aggregate is
empty, not its contents. Capture the declared top-level aggregate length
(*N / %N / ~N header) once per response in the parser -- alloc-free and
independent of keep_value -- and classify emptiness from it:
get_top_array_len() > 0 -> populated collection -> hit
0 -> empty (*0) or null (*-1) array -> miss
-1 -> reply was not a top-level aggregate -> miss
This reproduces the previous get_mbulk_value() structural semantics exactly,
including the two edge cases an interim get_hits()-based approach regressed:
- a collection of only zero-length elements (e.g. a set member "") counts as
a hit, not a miss (count comes from the header, not a per-value walk);
- a non-array misshape counts as a miss, matching the old top==NULL guard.
HGETALL/SMEMBERS/LRANGE no longer materialize reply values; ArrayPerElementNulls
(HMGET/MGET/ZMSCORE/GEOPOS) still does, as it needs per-position nulls.
Adds a regression test for the zero-length-member case.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
fcostaoliveira
force-pushed
the
fix/red-200840-emptycollection-misstracking-perf
branch
from
June 16, 2026 12:31
b87d08f to
1432068
Compare
fcostaoliveira
marked this pull request as ready for review
June 16, 2026 12:57
fcostaoliveira
deleted the
fix/red-200840-emptycollection-misstracking-perf
branch
June 16, 2026 14:36
fcostaoliveira
added a commit
that referenced
this pull request
Jun 16, 2026
…rbitrary commands (#469) Arbitrary-command miss-tracking (auto, default-on since v2.4.x) forced set_keep_value(true) for EmptyCollection-shaped replies (HGETALL, SMEMBERS, LRANGE, ...). That makes the protocol parser malloc + memcpy every element of every reply just to later check whether the top-level array was empty, costing 5-11% throughput on the hash datapath nightly (RED-200840). EmptyCollection only needs to know whether the reply's top-level aggregate is empty, not its contents. Capture the declared top-level aggregate length (*N / %N / ~N header) once per response in the parser -- alloc-free and independent of keep_value -- and classify emptiness from it: get_top_array_len() > 0 -> populated collection -> hit 0 -> empty (*0) or null (*-1) array -> miss -1 -> reply was not a top-level aggregate -> miss This reproduces the previous get_mbulk_value() structural semantics exactly, including the two edge cases an interim get_hits()-based approach regressed: - a collection of only zero-length elements (e.g. a set member "") counts as a hit, not a miss (count comes from the header, not a per-value walk); - a non-array misshape counts as a miss, matching the old top==NULL guard. HGETALL/SMEMBERS/LRANGE no longer materialize reply values; ArrayPerElementNulls (HMGET/MGET/ZMSCORE/GEOPOS) still does, as it needs per-position nulls. Adds a regression test for the zero-length-member case. Co-authored-by: Claude Opus 4.8 <[email protected]>
fcostaoliveira
added a commit
that referenced
this pull request
Jun 16, 2026
…prometheus-exporter Resolves tests/test_requirements.txt by keeping both new deps (prometheus_client for the exporter suites + psutil for master's CPU cross-validation). Source files (run_stats, client, memtier_benchmark) auto-merged; verified: both build flavors compile, make check + format-check green, statsd wire test 4/4 (one-producer refactor intact), live /metrics scrape 200. Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Jun 16, 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.
Summary
Arbitrary-command miss-tracking (
--command-miss-tracking=auto, default-on since v2.4.x) forcedset_keep_value(true)forEmptyCollection-shaped replies — HGETALL / SMEMBERS / LRANGE / .... That makes the protocol parsermalloc+memcpyevery element of every reply just to later check whether the top-level array was empty, costing 5–11% throughput on the hash datapath nightly and producing false 3%-baseline failures since build 7384 (RED-200840).EmptyCollectiononly needs to know whether the reply's top-level aggregate is empty — not its contents. This PR captures the declared top-level aggregate length (*N/%N/~Nheader) once per response in the parser (alloc-free, independent ofkeep_value) and classifies emptiness from it:get_top_array_len()> 00*0) or null (*-1)-1This reproduces the previous
get_mbulk_value()structural semantics exactly, while dropping the materialization.Correctness
An interim
get_hits()==0approach was caught (by adversarial review) to regress two cases; the declared-length approach handles both correctly:"") → hit, not miss (count comes from the header, not a per-value walk);top == NULLguard.ArrayPerElementNulls(HMGET / MGET / ZMSCORE / GEOPOS) still materializes — it needs per-position nulls.Testing
test_arbitrary_smembers_zero_length_member_is_hitregression test.Notes / follow-ups
fill_pipelinebufferevent_enable/BEV_LOCK(see perf(fill_pipeline): make bufferevent_enable conditional on m_bev_paused #448) and is out of scope here.🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.8 [email protected]
Note
Medium Risk
Touches the benchmark hot path and arbitrary-command miss accounting; behavior is intended to match prior semantics but parser edge cases (RESP3 push/attribute frames) are involved.
Overview
EmptyCollection miss tracking (e.g. SMEMBERS, HGETALL, LRANGE) no longer turns on
set_keep_value(true), so those replies are not fully materialized on the hot path. Only ArrayPerElementNulls commands still force value keeping.The RESP parser records the declared top-level aggregate length from the reply header (
*N/%N/~N) onprotocol_responseviaget_top_array_len(). EmptyCollection hit/miss logic uses that count instead of walkingget_mbulk_value(), so empty vs populated collections stay correct (including sets whose only member is an empty string) without malloc/memcpy per element.Adds
test_arbitrary_smembers_zero_length_member_is_hitto lock in declared-length behavior.Reviewed by Cursor Bugbot for commit 1432068. Bugbot is set up for automated code reviews on this repo. Configure here.