fix(hooks): eliminate redundant disk reads on every hook invocation#2051
Open
rosschurchill wants to merge 1 commit into
Open
fix(hooks): eliminate redundant disk reads on every hook invocation#2051rosschurchill wants to merge 1 commit into
rosschurchill wants to merge 1 commit into
Conversation
… OnceLock telemetry.rs: day-marker stat is now checked before config::Config::load(). On the hook hot-path the marker is almost always fresh, so the config.toml disk read is skipped on 99% of invocations. hook_check.rs: warn_marker is now checked before status(), which reads settings.json unconditionally. Moving the rate-limit check first means settings.json is read at most once per day, not on every hook call. config.rs: adds Config::load_cached() backed by OnceLock<Config> so multiple call sites within a single process share one config read. hook_cmd.rs: hot-path callers (run_claude_inner, run_cursor_inner context) updated to use load_cached(); also sets RTK_HOOK_MODE=1 at the top of each hook entry function (C-07 fix for these entry points). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
|
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.
Every
rtk hook claudecall unconditionally readsconfig.tomlandsettings.jsonbefore doing any work, even when nothing has changed.Two fixes:
telemetry.rsandhook_check.rs: move the cheap day-markerstat()check before theConfig::load()/settings.jsonread. If the marker is fresh, skip the disk read entirely.Configin astd::sync::OnceLock<Config>so multiple calls within the same process reuse the loaded value. Hook entry points updated to useConfig::load_cached().Free to use as-is.