Skip to content

Add per-command CPU time to SLOWLOG - #15907

Merged
StavRLevi merged 15 commits into
redis:unstablefrom
StavRLevi:RED-201674
Nov 5, 2026
Merged

StavRLevi merged 15 commits into
redis:unstablefrom
StavRLevi:RED-201674

Conversation

@StavRLevi

@StavRLevi StavRLevi commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Slow commands are often blamed on CPU starvation without evidence. The slowlog
records how long a command took, not whether the thread was actually running
during that time.

SLOWLOG GET field 8: CPU time (µs)

An upper bound on the thread's CPU time for the command:
min(duration, CPU used in the command's window). Close to the duration means
the command was running; much lower means it mostly was not.

0 means not measured: commands shorter than 10ms, off-cpu-tracking no,
the unblock path (e.g. a timed-out BLPOP), and a command re-executed after
blocking.
The reply grows from 7 to 8 elements.

How one cycle is split across commands

Sampling around every command costs ~0.3µs/command (−30% pipelined
throughput), so instead:

  1. When the event loop wakes, one sample is taken (clock, thread CPU time,
    context-switch counts). It's the checkpoint.
  2. Each command copies the current checkpoint when it starts (free, no syscall).
  3. A command is sampled again only if it's inserted into the slowlog and took
    at least 10ms. That sample becomes the checkpoint for whatever comes next.
    Shorter commands take no sample.

For that command:

window_cpu = CPU used since its checkpoint copy
cpu        = min(duration, window_cpu)   (it can't have used more CPU than
                                          the window did, nor more than it ran)
off_min    = duration − cpu              (off-CPU time that must be inside it)

Example: wakeup, fast command A (5ms), a 200ms context switch, then B (100ms).
At B's end: window = 305ms, window_cpu = 105ms, so B's cpu = min(100, 105) =
100 and off_min = 0. The 200ms happened before B, so it's not charged to B;
the cycle check reports it.

Detections: log lines and INFO counters

Two checks, one rule: reported when the guaranteed off-CPU time is at least
10ms.

Per command: only commands inserted into the slowlog are checked. Counted
in slow_command_off_cpu_events.

Slow command off-CPU (starvation): took 15000us, at least 13990us off-CPU (up to 14000us), 300 involuntary / 0 voluntary context switches

Per event-loop cycle: checked when the cycle took at least
max(slowlog-log-slower-than, 10ms). Counted in eventloop_off_cpu_events.
This exists because preemption between fast commands never produces a
slowlog entry.

Event loop cycle off-CPU: took 657274us, 656268us off-CPU, 16 commands, 12 involuntary / 3 voluntary context switches

Both share a limit of one log line per second; the next printed line reports
how many were suppressed. INFO counts every detection, including suppressed
ones. A slow command and its cycle can both count: one asks whether that
command was off-CPU, the other whether that wakeup was. CONFIG RESETSTAT
clears both counters.

Label

The context-switch counts tell how many switches happened, not how long each
lasted, so a label is printed only when it's certain:

  • only involuntary switches (ru_nivcsw: the kernel took the CPU away
    while the thread was runnable) → (starvation)
  • only voluntary switches (ru_nvcsw: the thread waited, e.g. a blocking
    syscall, disk, a lock, a major page fault) → (blocked)
  • both → no label; the off-CPU time and both counts are printed

Cycle measurement

The wakeup sample is also kept as the cycle start, and commands never move it.
The cycle is measured at the end of beforeSleep(), after commands handed
over by IO threads, so they are inside the window. The AOF write/fsync
duration (already measured) is subtracted from the off-CPU time, so disk waits
aren't counted. Nested event processing (processEventsWhileBlocked) returns
before this check.

Config

off-cpu-tracking yes|no (default yes, changeable with CONFIG SET).

  • yes: one CPU sample per event-loop wakeup, plus one per slow command/cycle.
  • no: no sampling at all, so no cost. SLOWLOG field 8 is 0, there are no
    off-CPU log lines, and the counters stay 0.
  • Turning it on takes a fresh sample, so the time it was off is never reported
    as off-CPU. Commands that started while it was off aren't measured.

Otherwise it follows the slowlog: a command is checked only when it's inserted
into the slowlog, and a cycle only when it takes at least
slowlog-log-slower-than. A hard-coded 10ms minimum applies on top: shorter
stalls are normal scheduling, and a low threshold shouldn't make commands pay
for getrusage(). Reports depend only on the measured off-CPU time (≥ 10ms).

Limitations

  • Waiting for a CPU right after waking from epoll_wait isn't measured,
    because the window starts once the thread runs.
  • Run-queue wait after a voluntary sleep adds no involuntary switch, so it can
    be labeled blocked.
  • Commands run from a module thread are sampled before and after every command
    (their duration isn't known in advance), so on that path the 10ms minimum
    only skips the report, not the sampling.
  • Without RUSAGE_THREAD (e.g. macOS), the fallback RUSAGE_SELF includes
    other threads' CPU and switches, so off-CPU time reads lower, detections can
    be missed, and labels are rare.

Testing

tests/unit/slowlog.tcl:

  • 8-field reply; CPU field below wall time for DEBUG SLEEP
  • DEBUG SLEEP → off-CPU log line and counter
  • a CPU-bound EVAL (above the 10ms minimum) gets a non-zero estimate
  • off-CPU time before a command isn't blamed on it: the same EVAL alone,
    then after 75ms of sleeps, reports about the same CPU time
  • an on-CPU subcommand doesn't hide a later off-CPU one (EVAL then
    DEBUG SLEEP inside EXEC)
  • off-cpu-tracking no → field 8 is 0 and nothing is reported; turning it
    back on after an idle period reports nothing false, and measuring resumes
  • CONFIG RESETSTAT clears both counters
  • real starvation (server pinned with 3 busy loops on one CPU at nice 19,
    Linux only): a Lua loop is reported per command, and 10×1000 pipelined SETs
    per cycle

tests/unit/moduleapi/misc.tcl: module commands that run DEBUG SLEEP via
RM_Call, one and two levels deep, keep the off-CPU time of the inner command.

Performance

CE Performance Automation, n=3, pinned bare-metal (m7i.metal-24xl /
m8g.metal-24xl), against the PR's merge-base (b78a80bd):

| test (worst case: one request per wakeup)
|---|---|---|
| zrank-100K-pipeline-1 | −1.7% |
| zrevrank-1M-pipeline-1 | −1.5% |

The cost is one sample per event-loop wakeup, so it shows only when each
request is its own wakeup; the broader string/hash/sorted-set/list regression
gate showed no consistent regression. off-cpu-tracking no removes it.

A variant reading run_delay from /proc/thread-self/schedstat (exact time
waiting for a CPU vs blocked) was also benchmarked: same cost on amd64,
1–1.5% worse on arm64, so it's left for a possible follow-up.


Note

Medium Risk
Changes the hot path (event loop and call()/slowlogPushCurrentCommand) and extends the SLOWLOG wire format; default-on sampling can reduce throughput on non-pipelined workloads though off-cpu-tracking no disables it.

Overview
Adds off-CPU tracking so slow commands and long event-loop cycles can be distinguished from true CPU work. SLOWLOG GET replies grow from 7 to 8 elements: field 8 is an upper-bound CPU time (µs) for the command (0 when not measured).

Sampling is cheap on the main thread: one getrusage checkpoint per event-loop wakeup, with an extra sample only when a command is actually written to the slowlog and ran ≥10ms. call() copies that checkpoint per command; slowlogMeasureCpu() derives CPU vs off-CPU bounds and may emit rate-limited Slow command off-CPU warnings plus slow_command_off_cpu_events in INFO stats. offCpuCheckEventLoopCycle() at the end of beforeSleep() reports starvation between fast commands (AOF flush time excluded) via Event loop cycle off-CPU lines and eventloop_off_cpu_events.

New modifiable config off-cpu-tracking (default yes, documented in redis.conf) resets the CPU window when re-enabled. Client timing resets go through resetClientCommandDuration() (wall + CPU fields). Module-thread RM_Call paths sample per command and nested slow calls attribute off-CPU to outer commands; tests cover slowlog shape, DEBUG SLEEP, EXEC, config toggle, and Linux CPU-pinning starvation.

Reviewed by Cursor Bugbot for commit 733c0f7. Bugbot is set up for automated code reviews on this repo. Configure here.

StavRLevi and others added 2 commits October 6, 2026 09:40
…low commands

Slow commands are often blamed on CPU starvation without evidence. For
every slowlog-worthy command, record how much of its time it actually ran
on-CPU, and log/count commands that were off-CPU for long enough to be
slow on that alone, classified as starvation (preempted) or blocked.

CPU time is sampled once per event-loop wakeup and once per slow command,
so fast commands pay no extra syscall.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mands)

Fast commands are too short to be preempted mid-command, so starvation
between them never reaches the slowlog. Check each event-loop cycle as a
whole: if the cycle reaches slowlog-log-slower-than, sample once more and
report it when its off-CPU time alone reaches the threshold, classified
as starvation or blocked like slow commands.

The cycle uses its own sample from afterSleep(), never moved by commands,
so duration, off-CPU time and command count describe the same window.
New INFO stats: eventloop_cpu_starvation_events,
eventloop_off_cpu_blocked_events. The one-per-second log limit is shared
with the per-command line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/server.c Resolved
Comment thread src/server.c Resolved
Comment thread src/server.c Resolved
@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.82609% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.11%. Comparing base (b78a80b) to head (733c0f7).
⚠️ Report is 107 commits behind head on unstable.

Files with missing lines Patch % Lines
src/server.c 92.30% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable   #15907      +/-   ##
============================================
+ Coverage     77.28%   78.11%   +0.83%     
============================================
  Files           146      156      +10     
  Lines         87988    95245    +7257     
============================================
+ Hits          67998    74404    +6406     
- Misses        19990    20841     +851     
Files with missing lines Coverage Δ
src/blocked.c 98.21% <100.00%> (ø)
src/commands.def 100.00% <ø> (ø)
src/config.c 86.83% <100.00%> (+1.19%) ⬆️
src/module.c 84.82% <100.00%> (+2.02%) ⬆️
src/networking.c 93.28% <100.00%> (+0.90%) ⬆️
src/server.h 100.00% <ø> (ø)
src/slowlog.c 98.21% <100.00%> (+1.58%) ⬆️
src/server.c 89.94% <92.30%> (+0.02%) ⬆️

... and 83 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

A slow command called from a script or a module (RM_Call) moved the CPU
checkpoint before the outer command was logged, so the outer command's
window started after it and it was stored as mostly on-CPU. Only
top-level commands move the checkpoint now; the off_min bound already
keeps each command from being blamed for time outside it.

Also note at the cycle check that it isn't reached while nested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fcostaoliveira

Copy link
Copy Markdown
Collaborator

This change touches performance-sensitive code paths. Adding the action:run-benchmark label will trigger the CE Performance suite so we can see the impact before merge.

@StavRLevi StavRLevi added the action:run-benchmark Triggers the benchmark suite for this Pull Request label Oct 6, 2026
@oranagra

oranagra commented Oct 7, 2026

Copy link
Copy Markdown
Member

there are quite a few things i don't understand when reading the PR description, maybe it can be improved instead of explaining it to me.

  1. i understand that new column in the slowlog is the upper bound CPU time of the command (not the offcpu time), but how do we attribute it to individual commands, e.g. in a long event loop that run for 500ms with many commands, and possibly more than one fitting into the slowlog?
  2. the log lines are printed (one per second)
    • for commands, only when we recorded a slowlog that's proven to be solely because of starvation?
    • what's the difference between starvation and blocked? please add more detail about the context switches you're counting
    • i see you're measuring cpu late in the beforeSleep function (after doing IO to AOF, i suggest moving upwards)
  3. please provide more details on the info fields, do they count the 2 above log prints?

Comment thread src/server.c Resolved
Comment thread src/server.c Resolved
StavRLevi and others added 2 commits October 11, 2026 10:42
…ore AOF flush

Move the off-CPU code (sampling, per-command estimate, classification,
rate-limited log, cycle check) from server.c into slowlog.c; server.c keeps
only the calls. No behavior change.

Run the event-loop cycle check before the AOF write/fsync in beforeSleep(),
so disk waits are no longer counted as off-CPU time of the cycle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/slowlog.c Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/slowlog.c Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/blocked.c Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/slowlog.c Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/server.c Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/server.c Resolved
@oranagra

Copy link
Copy Markdown
Member

More involuntary than voluntary → "starvation", otherwise "blocked".

i'm not sure this is good, in theory there could be many short voluntary, and one long involuntary or the other way around. the only way to know for sure is if one is 0 and we attribute all the lost time to the other.
in the other cases (both non-zero), maybe it's a better idea to just state the facts, rather than state a false conclusion.

slowlog-max-len 0 disables the command detector only.

i'm not certain what it means? that we'll record slowlog for every command, but won't measure CPU usage for them? and still keep measuring CPU usage for the event loop?
i think it's dangerous to enable this mechanism when slowlog threshold is low (e.g. 1ms, or even 10ms).
we can consider letting it kick in only above a certain command duration (regardless of the slowlog treshold).
e.g. only for commands slower than 50ms or something like that. and certainly not for 1ms.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 6c76665. Configure here.

Comment thread src/networking.c Resolved
@fcostaoliveira

fcostaoliveira commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

CE Performance Automation : step 1 of 2 (build) DONE.

This comment was automatically generated given a benchmark was triggered.
Started building at 2026-11-08 14:34:41.495431 and took 91 seconds.
You can check each build/benchmark progress in grafana:

  • git hash: 733c0f7
  • git branch: StavRLevi:RED-201674
  • commit date and time: n/a
  • commit summary: n/a
  • test filters:
    • command priority lower limit: None
    • command priority upper limit: None
    • test name regex: .*
    • command group regex: .*

You can check a comparison in detail via the grafana link

@fcostaoliveira

fcostaoliveira commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

CE Performance Automation : step 2 of 2 (benchmark) RUNNING...

This comment was automatically generated given a benchmark was triggered.

Started benchmark suite at 2026-10-14 08:33:08.359556 and took 131.983365 seconds up until now.
Status: [--------------------------------------------------------------------------------] 0.28% completed.

In total will run 357 benchmarks.
- 356 pending.
- 1 completed:
- 1 successful.
- 0 failed.
You can check a the status in detail via the grafana link

Comment thread src/server.c Resolved
Comment thread src/server.c Resolved
Comment thread src/server.c Resolved
@minchopaskal

Copy link
Copy Markdown
Collaborator

CE Performance Automation : step 2 of 2 (benchmark) RUNNING...

This comment was automatically generated given a benchmark was triggered.

Started benchmark suite at 2026-10-14 08:33:08.359556 and took 131.983365 seconds up until now. Status: [--------------------------------------------------------------------------------] 0.28% completed.

In total will run 357 benchmarks. - 356 pending. - 1 completed: - 1 successful. - 0 failed. You can check a the status in detail via the grafana link

@fcostaoliveira do we have results ?

@minchopaskal

Copy link
Copy Markdown
Collaborator

slowlog-max-len 0 disables the command detector only.

i'm not certain what it means? that we'll record slowlog for every command, but won't measure CPU usage for them? and still keep measuring CPU usage for the event loop? i think it's dangerous to enable this mechanism when slowlog threshold is low (e.g. 1ms, or even 10ms). we can consider letting it kick in only above a certain command duration (regardless of the slowlog treshold). e.g. only for commands slower than 50ms or something like that. and certainly not for 1ms.

@StavRLevi is this addressed? @oranagra did you mean we should have config about the command duration

@StavRLevi

StavRLevi commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

Hi, yes, addressed with a hard-coded 10ms minimum rather than a config, Oran's suggestion. On the main thread, a command is measured only when it's inserted into the slowlog and took ≥10ms, and a cycle only when it took ≥ max(slowlog-log-slower-than, 10ms). So a 0 or 1ms threshold doesn't make short commands pay for getrusage. The only per cycle cost left is the single sample at wakeup, and off-cpu-tracking no disables everything. slowlog-max-len 0 disables only the per command check (no entries), not the cycle check.

slowlog-max-len 0 disables the command detector only.

i'm not certain what it means? that we'll record slowlog for every command, but won't measure CPU usage for them? and still keep measuring CPU usage for the event loop? i think it's dangerous to enable this mechanism when slowlog threshold is low (e.g. 1ms, or even 10ms). we can consider letting it kick in only above a certain command duration (regardless of the slowlog treshold). e.g. only for commands slower than 50ms or something like that. and certainly not for 1ms.

@StavRLevi is this addressed? @oranagra did you mean we should have config about the command duration

@fcostaoliveira

fcostaoliveira commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Benchmark results for this PR: head 733c0f75b vs its merge base b78a80bd1, median of 3 runs per side, ops/sec.

Benchmark x86 ARM
GET 10B +0.05% +0.21%
GET 10B, pipeline 10 +0.11% -0.32%
SET 10B (load) +0.25% +0.17%
SET 10B (load), pipeline 10 +0.42% +0.24%
SETNX 10B -1.98% +0.11%
HELLO -0.88% +0.17%
HELLO, pipeline 10 +0.34% +0.18%
PING, pipeline 10 -0.28% +0.31%
HGET/HGETALL/HKEYS/HVALS 100B -1.07% +0.11%
ZSCORE, pipeline 10 +0.31% -0.92%

AWS m7i.metal-24xl (x86) and m8g.metal-24xl (ARM).

No measurable impact. The x86 leans from the single-run results (HELLO, SET, SETNX) did not hold with more runs; the remaining deltas are within run-to-run range (SETNX x86: 4.2% base, 2.9% head).

@minchopaskal minchopaskal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@StavRLevi
StavRLevi merged commit 46cf4a8 into redis:unstable Nov 5, 2026
20 checks passed
@sundb sundb added release-notes indication that this issue needs to be mentioned in the release notes state:needs-doc-pr requires a PR to redis-doc repository and removed action:run-benchmark Triggers the benchmark suite for this Pull Request labels Nov 8, 2026
@sundb

sundb commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

mgravell added a commit to seredis/StackExchange.Redis that referenced this pull request Nov 23, 2026
…e.CpuTime

The 8th entry field (redis/redis#15907, 8.12 RC3) is the duration minus
the provable off-CPU time, distinguishing a command that ran slowly from
one starved of CPU. Parsed positionally past the client address/name and
argument count, so every historical entry length still parses: null when
the server did not send the field, zero (per the server) when it was not
measured. Gated SER011 with the rest of the 8.12 surface.
mgravell added a commit to seredis/StackExchange.Redis that referenced this pull request Nov 23, 2026
…011) (#3343)

* Redis 8.12 BITRANGEINTARRAY (bit enumeration): IDatabase.StringBitPositions (#3315)

* Plan: StringBitPositions (BITRANGEINTARRAY, Redis 8.12)

* Plan: record the behaviour observed against a local unstable build

* Redis 8.12 BITRANGEINTARRAY: IDatabase.StringBitPositions

Enumerates the set (or, with bit: false, the clear) bit positions in a
byte or bit range of a string or native bitmap, ascending, with an
optional LIMIT; the sibling of StringBitPosition (BITPOS). Reuses
ResultProcessor.Int64Array; the argument tail fits Message.Create, with
the default BYTE omitted as BITCOUNT/BITPOS do. Negative limit throws
client-side.

Gated [Experimental(Experiments.Server_8_12)] (SER011), with
RedisFeatures.v8_12_0 and RedisFeatures.StringBitPositions, matching the
BLESS branch so the two merge textually.

Tests: exact wire bytes for every option combination (BitPositionsRoundTrip),
and live tests in BitTests gated on v8_12_0, observed green against a
local build of unstable (6a5fee67) on RESP2 and RESP3.

Removes the BITRANGEINTARRAY row from the command coverage ledger.

* 8.12 RC2: pin the real pre-release version and run CI against the RC2 image

- RedisFeatures.v8_12_0 is now 8.11.241, which is what 8.12 RC2 reports
  (the earlier 8.12.0 placeholder made the gated tests skip on RC2)
- the test topology image defaults to redislabs/client-libs-test:8.12-rc2
- the cluster configs opt out of the new cluster-bus-port-protected-mode
  check, which otherwise refuses to start a plaintext cluster node on RC2

Validated locally against the RC2 topology: StringBitPositions live tests
and BitPositionsRoundTrip all pass, and the cluster forms cleanly.

* SortedSetScanLarge: count distinct members, tolerating ZSCAN duplicates

The 8.12 btree zset encoding can return duplicate members even for an
unmodified key (redis/redis#16158; the SCAN contract allows it), so the
test now asserts the distinct member count instead of the raw count.
All 8 cases pass against the RC2 topology.

* Set-member expiration (Redis 8.12): SADDEX / SEXPIRE / SPTTL / SPERSIST on IDatabase (#3340)

* Initial support for Redis 8.12 set-member expiration

The hash-field-TTL idea (7.4's HEXPIRE) brought to sets (redis/redis#15938,
8.12-rc2), mirroring the HashField* family:

- SetAddAndSetExpiry (SADDEX): add members and/or (re)set their expiration in
  one atomic call; When.NotExists/Exists map to MNX/MXX, which are
  all-or-nothing across the batch, exactly as HSETEX's FNX/FXX; the bare form
  discards an existing TTL, KEEPTTL keeps it
- SetMemberExpire (SEXPIRE/SPEXPIRE/SEXPIREAT/SPEXPIREAT by precision) ->
  ExpireResult[], per member
- SetMemberGetTimeToLive (SPTTL) and SetMemberGetExpireDateTime (SPEXPIRETIME)
  -> long[]
- SetMemberPersist (SPERSIST) -> PersistResult[]
- KeyNotificationType.SExpired ('sexpired', side-effect block), so the 8.12
  notification - including on the subkey channels, whose payload names the
  lapsed member - parses as a known type; GetSubKeys() already handles the
  payload

Gated [Experimental] behind SER011/Experiments.Server_8_12 and
RedisFeatures.v8_12_0 (8.11.241), both shared with #3261/#3315; the test
docker image moves to client-libs-test:8.12-rc2 as in those PRs.

Round-trip tests pin the exact wire bytes; the live tests (HashFieldTests
mirror) pass against the 8.12-rc2 topology on both protocols. Plan document
in notes/set-member-expiry/.

* SADDEX rides SetAdd: two Expiration overloads replace the four-per-arity SetAddAndSetExpiry surface

Review feedback (see the PR): Expiration already encodes EX/PX/EXAT/PXAT/KEEPTTL - exactly SADDEX's
expiration block - so the TimeSpan?/DateTime/keepTtl splits collapse and the surface is
SetAdd(key, value, Expiration, When, flags) and SetAdd(key, values, Expiration, When, flags), both
bool (+async): 8 members become 4, with no new method name. A required Expiration keeps overload
resolution away from the existing SetAdd members.

- Expiration.Persist is rejected (SADDEX has no PERSIST; SetMemberPersist is the way to remove
  member expirations) - previously it would have been sent as a bogus token.
- The overloads always send SADDEX: plain SADD is not an equivalent fallback for the no-expiry
  form, because bare SADDEX discards an existing member's TTL where SADD leaves existing members
  untouched; the XML docs call this out, and that the multi-value form reports only whether
  anything changed, not a count.
- The SetMemberExpire/GetTimeToLive/GetExpireDateTime/Persist family is unchanged (ExpireWhen's
  GT/LT cannot ride Expiration, and it mirrors the HashField shape).
- plan.md carries a revision note; SER011.md updated; all 50 SetMemberExpiry tests pass live
  against 8.12-rc2, 525 KeyPrefixed tests pass.

* Each set-member-expiry test deletes its key up front: SADDEX's changed-anything reply and the MNX/NX conditions make residue from a previous run (or the other protocol) look like a failure

* Redis 8.12 BLESS (eviction protection) support (#3261)

Adds KeyBless/KeyUnbless/KeyBlessFlags (+async) on IDatabase and
IServer.BlessedKeys (+async) over BLESS SCAN, with the BlessFlags enum,
gated behind SER011 (Server_8_12). SET/CLEAR are raised to primary-only;
GET stays replica-eligible. Adds bless/unbless keyspace notification types.

* CommandCoverage: the BLESS rows retire with #3261 (the ledger lists only unexposed commands)

* Redis 8.12 atomic sorted-set moves: ZMOVE / ZMOVEMEMBER on IDatabase (#3351)

redis/redis#16135 (8.12-rc3) adds ZMOVE, BZMOVE and ZMOVEMEMBER:

- SortedSetMove (ZMOVE MIN|MAX [COUNT]) - from the low or high end
- SortedSetMoveByScore (ZMOVE BYSCORE min max [COUNT]) - a score range
- SortedSetMoveMembers (ZMOVEMEMBER [NX|XX] MEMBERS n ...) - named members,
  with When as the per-member condition on the destination

Each returns SortedSetEntry[]?, null when nothing moved (the server's null
reply is never folded into an empty array). COUNT is sent if and only if the
caller gives one: for BYSCORE, no COUNT means the whole range, so the
SortedSetPop habit of eliding COUNT 1 is not copied.

The reply is nested [member, score] pairs in RESP2 as well as RESP3, unlike
ZPOPMIN, so SortedSetWithScores does not fit; NullableSortedSetEntryArray
is a strict nested-pair processor.

BZMOVE is not exposed (blocking; policy row in CommandCoverage.md).

Gated [Experimental] behind SER011 and the new RedisFeatures.v8_12_0_rc3
(8.11.242: rc2 does not have the commands); the test docker image moves to
client-libs-test:8.12-rc3.

* SLOWLOG GET: surface the 8.12 estimated-CPU-time field as CommandTrace.CpuTime

The 8th entry field (redis/redis#15907, 8.12 RC3) is the duration minus
the provable off-CPU time, distinguishing a command that ran slowly from
one starved of CPU. Parsed positionally past the client address/name and
argument count, so every historical entry length still parses: null when
the server did not send the field, zero (per the server) when it was not
measured. Gated SER011 with the rest of the 8.12 surface.

* Redis 8.12 GA: test against client-libs-test:8.12.0; SER011 stays while the library API settles

8.12.0 went GA on 2026-11-22. The docker test image moves from 8.12-rc3 to 8.12.0, and docs/exp/SER011.md now says the server is generally available while the library API remains experimental.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes state:needs-doc-pr requires a PR to redis-doc repository

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants