Skip to content
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

spl-time: Use KeQueryPerformanceCounter instead of KeQueryTickCount #326

Merged

Conversation

EchterAgo
Copy link

KeQueryTickCount seems to only have a 15.625ms resolution unless the interrupt timer frequency is increased, which should be avoided due to power usage.

Instead, this switches the zfs_lbolt, gethrtime and random_get_bytes to use KeQueryPerformanceCounter.

On my system this gives a 100ns resolution.

@EchterAgo
Copy link
Author

Maybe I should remove zfs_abs_to_nano.

@EchterAgo
Copy link
Author

I also noticed the performance benchmarks for checksums / raidz parity use this to select an algorithm, should make the results more accurate.

@EchterAgo
Copy link
Author

Maybe we should assert for freq.QuadPart < NANOSEC in gethrtime. I know that at the moment no Windows version goes below 100ns, but it could happen in the future.

@EchterAgo
Copy link
Author

I added the ASSERT and cache the division in freq.

@EchterAgo EchterAgo force-pushed the timer_improvement branch 3 times, most recently from 93bcad5 to e756236 Compare November 10, 2023 05:34
`KeQueryTickCount` seems to only have a 15.625ms resolution unless the
interrupt timer frequency is increased, which should be avoided due to
power usage.

Instead, this switches the `zfs_lbolt`, `gethrtime` and
`random_get_bytes` to use `KeQueryPerformanceCounter`.

On my system this gives a 100ns resolution.

Signed-off-by: Axel Gembe <[email protected]>
One less division for each call.

Signed-off-by: Axel Gembe <[email protected]>
@lundman lundman merged commit 3c86648 into openzfsonwindows:zfs-Windows-2.2.0-release Nov 10, 2023
7 checks passed
@EchterAgo EchterAgo deleted the timer_improvement branch November 10, 2023 05:39
lundman pushed a commit that referenced this pull request Dec 11, 2023
…326)

* spl-time: Use KeQueryPerformanceCounter instead of KeQueryTickCount

`KeQueryTickCount` seems to only have a 15.625ms resolution unless the
interrupt timer frequency is increased, which should be avoided due to
power usage.

Instead, this switches the `zfs_lbolt`, `gethrtime` and
`random_get_bytes` to use `KeQueryPerformanceCounter`.

On my system this gives a 100ns resolution.

Signed-off-by: Axel Gembe <[email protected]>

* spl-time: Add assertion to gethrtime and cache NANOSEC / freq division

One less division for each call.

Signed-off-by: Axel Gembe <[email protected]>

---------

Signed-off-by: Axel Gembe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants