-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8307766: Linux: Provide the option to override the timer slack #13889
Conversation
👋 Welcome back shade! A progress list of the required criteria for merging this PR into |
7c048d0
to
4251128
Compare
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is really of use to people then I expect it would also be useful to know what the current setting is for a thread - perhaps either logged at thread creation, or perhaps included in one of the thread print_on
functions?
Not sure what is being measured here but this looks odd. The first 10x increase to 100 results in a 100x increase. But then the next 10x is almost no difference, and the 10x after that not that much difference. |
Odd, right? This is how the 50us default timer slack value introduces jitter: you can turn around fast, or you can get stalled up to the timer slack. And this is precisely (pun intended) why I'd like to have some control over the timer slack :) |
Yes, that would be a good thing to add, see new commit. I tried to limit the fan-out for this change by printing the timer slack in Linux-specific thread init block, near the stack printing. |
I'm still not really understanding what this timer slack actually means in practice and how it relates to the sleep benchmark. |
Perhaps this LWN article would help: https://lwn.net/Articles/369549/
Larger timer slack => coarser timer expiration window => more opportunities to merge timers / keep CPUs at low power state => less accuracy / more efficiency. Timer slack affects |
Thanks. So are timer events only coalesced within a process, or is this system wide? I'm guessing the basic operation is that if a thread requests a "timed wait" that would require a timer event at time T1, but there already exists a timer event for time T2, (T2 > T1) then if T2-T1 < timer-slack then an event for T1 is not created and we piggy-back on the event for T2 instead. So the lower the slack the more likely we get our own timer-event and so get a resolution closer to that of the h/w, but it also means we have more timer-events to process so that could lower the resolution again. |
I have not read the kernel sources for this, but my recollection is that timer lists are maintained per-CPU + there is a migration mechanics, which effectively makes timers system-wide. So timer slack allows piggy-backing on hi-res timers already pending on the system, which improves efficiency at the accuracy cost. I suspect that even if we are the only timer currently pending, the kernel would still apply the timer slack to it, hoping that some other timer would be able to piggy-back on us. Which explains why a single-threaded Yes, I do wonder if we can blow out the kernel time subsystem with very low timer slack value, but that is something that needed to be checked for the concrete workload. Linux helpfully provides us the API to tune the heuristics either way, so this PR gives us the handy ability to experiment with it :) |
@shipilev This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
(Trying to revive this PR) Let me know if there are more comments to this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is experimental and seems non-intrusive I can approve it. But how will this be tested? Can we at least sanity check setting it and reading back the value we set?
Thanks.
Yes, and even more, see the new commit with a test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all seems reasonable to me.
Thanks.
@shipilev This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 10 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
RISC-V build failure looks like an infrastructure issue. I re-tested current patch on /integrate |
Going to push as commit 7173c30.
Your commit was automatically rebased without conflicts. |
See the description in the RFE.
On
c6.8xlarge
, the sleep accuracy is improved the following way:Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13889/head:pull/13889
$ git checkout pull/13889
Update a local copy of the PR:
$ git checkout pull/13889
$ git pull https://git.openjdk.org/jdk.git pull/13889/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 13889
View PR using the GUI difftool:
$ git pr show -t 13889
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13889.diff
Webrev
Link to Webrev Comment