Skip to content

feat(network): implement F-03 SLOWLOG with CONFIG tuning#42

Merged
phaethix merged 3 commits into
masterfrom
feat/slowlog
Jul 21, 2026
Merged

feat(network): implement F-03 SLOWLOG with CONFIG tuning#42
phaethix merged 3 commits into
masterfrom
feat/slowlog

Conversation

@phaethix

Copy link
Copy Markdown
Owner

No description provided.

phaethix added 3 commits July 21, 2026 14:24
Capture the approved design for the SLOWLOG command: a global bounded
ring on KvEngine with lock-free atomic tunables
(slowlog-log-slower-than, slowlog-max-len), an execute_command timing
hook, CONFIG GET/SET wiring, and a TDD task list with an integration
suite driven over a real TCP listener.

Verified: cargo fmt --all -- --check clean on the doc-only change
(no code yet).

Refs F-03
Add the SLOWLOG latency-observability command (GET [count] / LEN /
RESET) and runtime-tunable slow-log thresholds, completing the Phase 0
F-03 hardening item.

- protocol/parser: new Command::SlowLog with GET/LEN/RESET arity
  checks, plus Command::args() which reconstructs the RESP arg vector
  so the log records what was executed without keeping the raw frame.
- storage/engine: bounded global ring (Mutex<VecDeque>) plus two
  lock-free atomics for slowlog-log-slower-than (i64, default 10ms;
  -1 logs everything, 0 disables) and slowlog-max-len (default 128).
  maybe_push_slowlog records only when elapsed strictly exceeds the
  threshold; the ring trims oldest-first and ids are monotonic.
- network/server: execute_command gains a client SocketAddr param and a
  timing hook; SLOWLOG never logs itself. CONFIG GET/SET expose the
  two new parameters, reusing the existing validation style.

Verified: cargo fmt --all -- --check, cargo clippy --all-targets
--all-features -- -D warnings, cargo test --all-targets
--all-features (259 lib + integration, 0 failed), cargo bench
--no-run --all-features. No benchmark regression; the disabled hot
path takes no lock and clones nothing.

Refs F-03
Add deterministic coverage for the slow-log feature.

- storage/engine slowlog_tests: threshold semantics (0 disables,
  equal-to-threshold not logged, negative logs everything, strict
  exceed logs), monotonic newest-first ids, ring trim, GET
  count cap, reset, and entry arg/peer capture (duration is
  injected directly so no real timing is needed).
- protocol parser: SLOWLOG parse arity (GET/LEN/RESET, extra
  arg rejected, unknown subcommand rejected) and Command::args()
  reconstruction for SET/MSET/INCRBY/MEMORY/SLOWLOG.
- tests/slowlog_test.rs: end-to-end over a real TCP listener --
  CONFIG SET enables/disables, SLOWLOG GET records args and the
  loopback client address, RESET clears, CONFIG GET round-trips
  the defaults, and max-len rejects 0.
- resp2_wire_test: extend the CONFIG GET * assertion to the two
  new slowlog parameters.

Verified: cargo test --all-targets --all-features green
(0 failed).

Refs F-03
@phaethix
phaethix merged commit 61acb38 into master Jul 21, 2026
3 checks passed
@phaethix
phaethix deleted the feat/slowlog branch July 21, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant