Io report caller interval#60
Open
homm wants to merge 3 commits into
Open
Conversation
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Author
Co-authored-by: Codex <codex@openai.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.
This PR is a port of the timer-related changes from #59.
Sampling and calculation fixes
Sampling now matches the requested interval
Previously, a requested
1 sinterval was internally handled as4 x 250 mssamples plus an extra averaging pass, with the sampling loop implemented inIOReport::get_sample.In this branch, the same
1 sinterval is sampled as an actual1 sinterval instead of being split into smaller internal windows.That earlier
4 x 250 msscheme was introduced as a workaround for the behavior described in issue #10. However, the later investigation showed that the original problem had a different cause: the older implementation sampled only a fixed 80 ms window and then slept for the remainder of the interval, whileget_metricsused that short window as the sampling duration.Now that sampling is structured around consecutive real samples and their delta, the reported metrics are derived from the actual elapsed interval itself. Because of that, the extra
4 x 250 mssmoothing loop is no longer necessary. It also allowed theIOReportsampling path to become substantially simpler by removing the internal multi-sample orchestration that used to live inIOReport::get_sample.Interval management is now fully owned by the caller
Another related change is that sampling no longer sleeps internally.
Previously,
IOReportitself managed timing by sleeping between internal samples inIOReport::get_sample. In this branch, that responsibility is moved out ofIOReport::get_sample, which now just computes the delta between the previous sample and the current one. It does not block, does not sleep, and does not decide how often sampling should happen.This is a better separation of responsibilities:
IOReportis responsible only for sample-to-sample delta calculation;Reduced interval drift
The measurements and timings were changed since #59 to account for the 100ms minimum interval.
The same change also reduces drift across repeated short samples.
Startup time, which is not changed in this version:
Excluding the 100ms interval, it is about
2.925s - 100ms = 2.825s.With
-i 100 -s 100, the requested sampling time is100 x 100ms = 10s:The total runtime excluding startup dropped from about
21.015s - 2.825s = 18.19sto about12.821s - 2.825s = 9.996s, which perfectly matches the requested 10s. In the old versions, there was a large 8s drift due to ignoring theIOReportCreateSamplestime itself multiplied by 4.