Repository navigation
perf(fill_pipeline): make bufferevent_enable conditional on m_bev_paused - #448
Merged
fcostaoliveira merged 1 commit intoJun 2, 2026
Conversation
2.4 regression flagged by micro-bench: ~4% ops/sec drop on canonical SET/GET vs 2.3.1. Root cause: bufferevent_enable at the top of fill_pipeline was added in redis#390/redis#400 to recover from --transaction's hold_pipeline disable, but it fires every fill_pipeline invocation (per response received) -- taking libevent's BEV_LOCK in the hot path even when no pause/resume is needed. Track pause state with bool m_bev_paused; only call bufferevent_enable when the flag indicates the bufferevent was actually paused. Set the flag at the disable site, clear it at the existing enable sites (handle_event, schedule_fill, fill_pipeline's resume branch) and on bev (re)creation/teardown (setup_event, disconnect). Invariant: m_bev_paused == true iff bufferevent is in EV_READ|EV_WRITE disabled. Local micro-bench: server-bound runs against a single localhost Redis on this box stay within noise (~+0.3% on pipeline=32 clients=50 threads=4 ratio=1:1 300K reqs, 3 runs each) because Redis is the bottleneck. Forcing the client to be the bottleneck (taskset -c 0,1 clients=100 threads=2 pipeline=32 ratio=1:1 200K reqs, 3 runs each) shows +12.81% ops/sec recovery (322,237 -> 363,517). Functional parity verified with --transaction MULTI/SET/EXEC against a manual 3-node cluster (1:1:1 Multis:Sets:Execs ratio, no errors). Refs: 2.4 review redis#28 (Review 18 MED finding). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
fcostaoliveira
added a commit
that referenced
this pull request
Jun 2, 2026
…sed (#448) 2.4 regression flagged by micro-bench: ~4% ops/sec drop on canonical SET/GET vs 2.3.1. Root cause: bufferevent_enable at the top of fill_pipeline was added in #390/#400 to recover from --transaction's hold_pipeline disable, but it fires every fill_pipeline invocation (per response received) -- taking libevent's BEV_LOCK in the hot path even when no pause/resume is needed. Track pause state with bool m_bev_paused; only call bufferevent_enable when the flag indicates the bufferevent was actually paused. Set the flag at the disable site, clear it at the existing enable sites (handle_event, schedule_fill, fill_pipeline's resume branch) and on bev (re)creation/teardown (setup_event, disconnect). Invariant: m_bev_paused == true iff bufferevent is in EV_READ|EV_WRITE disabled. Local micro-bench: server-bound runs against a single localhost Redis on this box stay within noise (~+0.3% on pipeline=32 clients=50 threads=4 ratio=1:1 300K reqs, 3 runs each) because Redis is the bottleneck. Forcing the client to be the bottleneck (taskset -c 0,1 clients=100 threads=2 pipeline=32 ratio=1:1 200K reqs, 3 runs each) shows +12.81% ops/sec recovery (322,237 -> 363,517). Functional parity verified with --transaction MULTI/SET/EXEC against a manual 3-node cluster (1:1:1 Multis:Sets:Execs ratio, no errors). Refs: 2.4 review #28 (Review 18 MED finding). Co-authored-by: Claude Sonnet 4.6 <[email protected]>
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
2.4 regression flagged by micro-bench: ~4% ops/sec drop on the canonical SET/GET workload vs 2.3.1.
Root cause:
bufferevent_enable(m_bev, EV_READ | EV_WRITE)was added at the top ofshard_connection::fill_pipeline()in #390 / #400 to recover from--transaction'shold_pipelinedisable. Butfill_pipelineruns per response received, so this lock-taking libevent call (it takesBEV_LOCKinternally even on a no-op) fires at the request rate.Fix: Track pause state with a
bool m_bev_pausedflag. Only callbufferevent_enablewhen the flag indicates the bufferevent was actually paused.m_bev_paused == trueiffm_bevis in theEV_READ|EV_WRITE-disabled state.bufferevent_disablesite (idle-disable branch infill_pipeline).bufferevent_enablesite (fill_pipelineresume branch,handle_eventonBEV_EVENT_CONNECTED,schedule_fill), and on bev (re)creation / teardown (setup_event,disconnect).Validation
Functional (
--transaction)Verified against a manual 3-node OSS cluster with
--cluster-mode --transaction --command="MULTI" --command="SET tx_{tag}_key __key__" --command="EXEC"at pipeline=4, clients=4, threads=2:1:1:1 Multis:Sets:Execs ratio preserved (no transactions torn apart, no server-side errors).
Performance
Local micro-bench on a 14-core Intel Core Ultra 7 155U against a single localhost Redis 8.6.0. The canonical
pipeline=32 clients=50 threads=4 ratio=1:1run is server-bound on this hardware (~605K-620K ops/sec is the Redis ceiling on one core), so the client-side improvement is masked by Redis saturation:--pipeline=32 --clients=50 --threads=4 --requests=300K--pipeline=1 --clients=50 --threads=4 --requests=100KTo exercise the client side, pinned memtier to 2 cores (
taskset -c 0,1) to make the client the bottleneck:taskset -c 0,1 --pipeline=32 --clients=100 --threads=2 --requests=200KThe fix recovers the regression on client-bound workloads; the original 4% reported on the benchmark farm corresponds to a setup where the client is closer to the bottleneck than my localhost test rig.
Test plan
autoreconf -ivf && ./configure && make -j)--transactionsmoke against 3-node OSS cluster: 1:1:1 ratio preserved at pipeline=4--transactionsmoke against standalone (no-op warning + normal execution)taskset -c 0,1): +12.81% recoverymake format-check-staged)test_cluster_transaction.py,test_transaction_pipeline.py)Refs: 2.4 review #28 (Review 18 MED finding); regression introduced by #390 / #400.
Note
Low Risk
Localized libevent I/O gating in
shard_connectionwith an explicit pause flag; behavior change is skipping redundant enables on the steady-state path.Overview
Fixes a ~4% ops/sec regression on high-throughput SET/GET by stopping
fill_pipeline()from callingbufferevent_enable()on every response. That unconditional resume was added to undo idle/--transactionhold_pipelinepauses but runs in the hot path and takes libevent’sBEV_LOCKeven when I/O was already enabled.The change adds
m_bev_paused, set whenfill_pipelinedisables read/write on an idle connection and cleared on connect,schedule_fill, and other real enable paths.bufferevent_enablenow runs only when the connection was actually paused, preserving transaction and idle-disable behavior without per-response overhead.Reviewed by Cursor Bugbot for commit 04db221. Bugbot is set up for automated code reviews on this repo. Configure here.