perf(sqlite-native): gate kv operation labels#4633
Conversation
PR Review: perf(sqlite-native): gate kv operation labelsThis is a focused, well-targeted performance improvement. The changes are correct and align with the codebase conventions. Strengths Removing std::env::var(RIVET_TRACE_SQL) calls on the hot path is the most impactful change. These were called on every KV operation and involve an OS syscall + string comparison each time. Eliminating them is a meaningful reduction in overhead. Using format_args!() instead of format!() correctly avoids heap-allocating a String for the op label when DEBUG tracing is disabled. format_args! is lazy and only formats if the subscriber actually processes the event. Removing eprintln! calls aligns with the CLAUDE.md guideline: never use eprintln!/println! for logging in Rust, always use tracing macros. Suggestions
Minor The cosmetic reformatting of read_cache_enabled, existing_chunk, and flushed improves readability with no logic changes. Overall this is a clean, correct perf fix. The main actionable suggestion is optionally gating the Instant calls, though low priority. LGTM. |
5482e7d to
bde5c19
Compare
18d65ab to
349925c
Compare
bde5c19 to
13c73bd
Compare
349925c to
c7ac8f9
Compare
13c73bd to
768d9da
Compare

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: