feat(network): implement F-03 SLOWLOG with CONFIG tuning#42
Merged
Conversation
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
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.
No description provided.