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

feat(stat): use cputime for all timing related functions #1901

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jdrouhard
Copy link
Contributor

@jdrouhard jdrouhard commented Jan 23, 2025

Description

It's always baffled me why the 3 timings at the top of the Profile tab didn't match the individual timings of the profiles in the more detailed breakdown in the lower section. Decided to dive into this a bit and realized that cputime was being used for the main 3, but relative timings from one stage to the next were using vim.uv.hrtime() - <prev_snapshot>.

These are two different types of timings. I may have some changes soon that attempt to remedy this, but if the cputime() function is using the ffi clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ...) from the OS, it measures only the cpu time of the process, not the wall time from process start to the time of the call. Unfortunately this means the cputime measurement doesn't reflect actual elapsed time. When you mix and match these two, the times don't add up.

This PR aims to unify the times in the profile output so all the shown elapsed times are sourced by the same method. It moves cputime() to lazy.core.util and changes the stats' times[] to store nanoseconds instead of milliseconds.

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.

1 participant