-
Notifications
You must be signed in to change notification settings - Fork 24
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
about the difference between value of auto-detected linux_hz and CONFIG_HZ #21
Comments
Hello, It's probably expected to have a value different from CONFIG_HZ, however I wouldn't have expected to get such a higher tick frequency. I'm not sure how to reliably get this constant from C code across all linux kernel versions, and we also need an alternative for non-linux kernel. It's however possible to manually set this parameter if needed. That being said, this parameter is only used as a way to ignore incorrect getrusage() result that we previously saw when graphing the results using powa UI. I'm fine with improving this part, but I'm afraid that whatever approach we use, we'll never be able to really trust numbers for queries which runtime is close to the system clock resolution. |
After a quick look at A simple way to fix that would be to add a new loop that call getrusage until a new timeval is found, and then use this as a reference for the existing loop to compute a more reliable hz. What do you think? |
Thanks for your reply!
Oh, I thought it should be CONFIG_HZ. I misunderstand something?
Just out of interest, 'incorrect getrusage() result' is how incorrect?
Uhh, sorry, but I cannot judge this idea works well or not.. |
The parameter should have this value. If the user doesn't configure it manually (since I don't know any way to conveniently retrieve it from a C program), there's a heuristic trying to find the value.
Both. Let's say the clock resolution is 1ms, if you have 10 queries running for 0.1 ms, pg_stat_kcache could then report 9 of them being instant as far as CPU is concerned, and one of them lasting 1ms. If you have 10 different queryid, then 9 of those queries will appear as not consuming any CPU while the last one would appear as consuming more cpu time than execution time, so the cpu usage would be more than 100%. |
Oh, it also seems that the computation is done using the wrong unit:
This is computing a frequency based on microseconds and not milliseconds, so that explains why you got 500000 rather than 500. Both values are wrong (I'm assuming that you're LINUX_HZ is 1000), but at least 500 is the right order of magnitude. |
Thanks for your investigation, I haven't noticed that! |
Hello,
I have little knowledge on kernel time and I may have basic misunderstanding, but I noticed that auto-detected linux_hz is different from the CONFIG_HZ.
I first tried this on a virtual machine, and doubted VM might be the cause.
So I also tried the same thing on a physical server, but the guessed linux_hz is far more than CONFIG_HZ.
Is this an intentional behavior?
And as far as I read the explanation of linux_hz and man time(7), it seems better to set the value of CONFIG_HZ to linux_hz, is this a right way to go?
The text was updated successfully, but these errors were encountered: