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

get boot time each time cost too much cpu #1070

Open
hz-kelpie opened this issue May 10, 2021 · 5 comments
Open

get boot time each time cost too much cpu #1070

hz-kelpie opened this issue May 10, 2021 · 5 comments

Comments

@hz-kelpie
Copy link

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~

@Lomanic
Copy link
Collaborator

Lomanic commented May 17, 2021

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

See also #857/#837

@hz-kelpie
Copy link
Author

Thanks for your response, I think you are right
can i skip the step getting boot time , It's bit of a waste of time

@hz-kelpie
Copy link
Author

Because this method has a lock
I can't reduce the CPU even with concurrency

@ghost
Copy link

ghost commented Dec 20, 2021

Meet the same question. "process.NewProcessWithContext()" blocked in my situation when using pprof to monitor go routine stacks. And I found another problem, "process.NewProcessWithContext()" seems not using context (1th param) as a timeout control threshold. Then block may happen.
image

@cforce
Copy link

cforce commented Nov 1, 2023

@hz-kelpie Is this unnecessary step getting boot time meanwhile dropped from the codebase and merged? Can this issue then get solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants