-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
get boot time each time cost too much cpu #1070
Comments
We can't cache host.BootTime as it can jump if time gets adjusted (like with ntpd) Tested on a Raspberry Pi pi@raspberrypi:~ $ grep btime /proc/stat
btime 1621271964
pi@raspberrypi:~ $ sudo systemctl disable systemd-timesyncd
pi@raspberrypi:~ $ sudo systemctl stop systemd-timesyncd
pi@raspberrypi:~ $ sudo systemctl disable fake-hwclock.service
pi@raspberrypi:~ $ sudo systemctl stop fake-hwclock.service
pi@raspberrypi:~ $ sudo reboot
# after reboot
pi@raspberrypi:~ $ grep btime /proc/stat
btime 1550139115
pi@raspberrypi:~ $ sudo systemctl enable systemd-timesyncd
pi@raspberrypi:~ $ sudo systemctl start systemd-timesyncd
pi@raspberrypi:~ $ grep btime /proc/stat
btime 1621272415
# btime jumped |
Thanks for your response, I think you are right |
Because this method has a lock |
@hz-kelpie Is this unnecessary step getting boot time meanwhile dropped from the codebase and merged? Can this issue then get solved? |
i use process.NewProcess(pid) 1000 processes per second
but common.BootTimeWithContext() runs every time,it depends on syscall.Syscall, it's blocked
maybe there's some way I don't know to cache the Process.starttime?
thx~
The text was updated successfully, but these errors were encountered: