-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
improve maitake timer wheel #475
Merged
Merged
Conversation
This file contains 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
This commit adds a new type to the `maitake::time` module, called `Clock`. A `Clock` bundles together a base duration and a `now()` function, making it easier for libraries to define time sources to be used with `maitake::time`.
Now that we have a trait for hardware clocks, we expect the hardware timestamp to always come from the clock, rather than being passed in when the timer wheel is turned. This commit changes the timer APIs so that, rather than advancing the timer wheel to a particular `now` time, we instead call `Timer::turn`, which advances the wheel to "whatever the `Clock` thinks the current time is". This also means we can get rid of `pending_ticks`, which I always kinda hated.
It would be really nice to be able to use RDTSC as the timestamp source on x86_64, as it's the nicest hardware timer available on newer x86 CPUs. This commit starts on implementing a calibration routine for RDTSC, although it's not quite done.
Unfortunately, my RDTSC calibration code from 9d549a3 is not that good, and using RDTSC currently results in a bunch of weird time travel bugs. This commit puts back the less accurate interrupt-driven clock for now. I'll finish RDTSC later once the timer wheel changes land.
I'm a dumbass lmao
This commit changes the construction of new `Sleep`s to use the nice `Clock` API.
This commit changes the `Sleep` future in `maitake::time` to turn the timer to the `Clock`'s current `now()` time when the timer wheel lock is acquired to register a new `Sleep`. This way, the timer is (at least occasionally) turned while polling `Sleep`s, in addition to when scheduled by an interrupt or by a scheduler tick completing. This way, we fire completing sleeps much more frequently, which should help improve the timer's accuracy substantially. Because we only do this when the timer wheel lock already has to be acquired to register the `Sleep` in the first place, this shouldn't increase contention for the wheel lock all that much. Fixes #474
hawkw
added a commit
that referenced
this pull request
Feb 25, 2024
hawkw
added a commit
that referenced
this pull request
Mar 5, 2024
hawkw
added a commit
that referenced
this pull request
Mar 17, 2024
This commit adds examples for the new `time::Clock` API, and removes references to `Timer::advance`/`Timer::force_advance`.
hawkw
added a commit
that referenced
this pull request
Mar 17, 2024
This commit adds a new type to the `maitake::time` module, called `Clock`. A `Clock` bundles together a base duration and a `now()` function, making it easier for libraries to define time sources to be used with `maitake::time`.
hawkw
added a commit
that referenced
this pull request
Mar 17, 2024
Now that we have a trait for hardware clocks, we expect the hardware timestamp to always come from the clock, rather than being passed in when the timer wheel is turned. This commit changes the timer APIs so that, rather than advancing the timer wheel to a particular `now` time, we instead call `Timer::turn`, which advances the wheel to "whatever the `Clock` thinks the current time is". This also means we can get rid of `pending_ticks`, which I always kinda hated.
hawkw
added a commit
that referenced
this pull request
Mar 17, 2024
It would be really nice to be able to use RDTSC as the timestamp source on x86_64, as it's the nicest hardware timer available on newer x86 CPUs. This commit starts on implementing a calibration routine for RDTSC, although it's not quite done.
hawkw
added a commit
that referenced
this pull request
Mar 17, 2024
Unfortunately, my RDTSC calibration code from 9d549a3 is not that good, and using RDTSC currently results in a bunch of weird time travel bugs. This commit puts back the less accurate interrupt-driven clock for now. I'll finish RDTSC later once the timer wheel changes land.
hawkw
added a commit
that referenced
this pull request
Mar 17, 2024
hawkw
added a commit
that referenced
this pull request
Mar 17, 2024
This commit changes the construction of new `Sleep`s to use the nice `Clock` API.
hawkw
added a commit
that referenced
this pull request
Mar 17, 2024
This commit changes the `Sleep` future in `maitake::time` to turn the timer to the `Clock`'s current `now()` time when the timer wheel lock is acquired to register a new `Sleep`. This way, the timer is (at least occasionally) turned while polling `Sleep`s, in addition to when scheduled by an interrupt or by a scheduler tick completing. This way, we fire completing sleeps much more frequently, which should help improve the timer's accuracy substantially. Because we only do this when the timer wheel lock already has to be acquired to register the `Sleep` in the first place, this shouldn't increase contention for the wheel lock all that much. Fixes #474
hawkw
added a commit
that referenced
this pull request
Mar 17, 2024
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.
fixes #474