feat(sight): opt-in timer_slack optimization for agent wakeup latency#725
Open
jfeng18 wants to merge 2 commits into
Open
feat(sight): opt-in timer_slack optimization for agent wakeup latency#725jfeng18 wants to merge 2 commits into
jfeng18 wants to merge 2 commits into
Conversation
73a94e9 to
dee99de
Compare
Adds --optimize-timer-slack flag that writes timer_slack_ns=1 to /proc/<pid>/timerslack_ns for traced agent processes. This reduces the kernel's hrtimer coalescing window from 50us to 1ns. Profiling data (ECS 2-core, bpftrace sched_wakeup→sched_switch): - Default: p90 tail at 512-2K us (36% of samples >512us) - With timer_slack=1: tail halved (15% of samples >512us) The optimization also tightens select/poll/epoll_wait timeouts, which benefits agents doing network I/O. Opt-in only (default off) — this crosses the observation/actuation boundary. Requires root (CAP_SYS_NICE for cross-process write). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5dc635e to
7e99112
Compare
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.
Summary
Adds
--optimize-timer-slackflag that writestimer_slack_ns=1to/proc/<pid>/timerslack_nsfor traced agent processes, reducing the kernel hrtimer coalescing window from 50us (default) to 1ns.Profiling evidence (ECS 2-core, bpftrace)
The optimization also tightens
select/poll/epoll_waittimeouts (select_estimate_accuracy()in kernel usestimer_slack_ns), directly benefiting agent network I/O.Design
--optimize-timer-slackCLI flag/proc/<pid>/timerslack_ns(requires CAP_SYS_NICE, which root has)Kernel cross-reference (cloud-kernel 6.6)
hrtimer.c:2338:hrtimer_set_expires_range_ns(timer, rqtp, current->timer_slack_ns)proc/base.c:2642: writing 0 resets to default; writing 1 is minimum effective valueselect.c:80:select_estimate_accuracy()usestimer_slack_nsfor poll/select/epollTest plan