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

fix clock resolution detection #16720

Merged
merged 5 commits into from Jan 3, 2024
Merged

Conversation

ktsaou
Copy link
Member

@ktsaou ktsaou commented Jan 3, 2024

Closes: #16710

netdata reads the system's clock resolution to understand the steps it should pause to synchronize data collection.

On some systems clock_getres() is broken. It either returns an error, or it returns invalid values.

Now netdata checks that clock_getres() returns success and also that the the value in usec is bigger than zero and less than 10ms.

If successful, it rounds the clock precision in usec and returns it back. Resolutions smaller than 1 usec are rounded to 1 usec.

If unsuccessful, it returns the default clock resolution of 1ms.

thiagoftsm
thiagoftsm previously approved these changes Jan 3, 2024
@ktsaou ktsaou merged commit 09db66c into netdata:master Jan 3, 2024
128 checks passed
@ilyam8
Copy link
Member

ilyam8 commented Jan 3, 2024

The bug was in

static usec_t get_clock_resolution(clockid_t clock) {
struct timespec ts;
clock_getres(clock, &ts);
return ts.tv_sec * USEC_PER_SEC + ts.tv_nsec * NSEC_PER_USEC;
}

must be ts.tv_nsec / NSEC_PER_USEC;

stelfrag pushed a commit to stelfrag/netdata that referenced this pull request Jan 31, 2024
* fix clock resolution detection

* print the delta

* make sure the resolution is usec_t

* use defines for default and max resolution

* fixed wrong calculation

(cherry picked from commit 09db66c)
@stelfrag stelfrag mentioned this pull request Jan 31, 2024
tkatsoulas pushed a commit that referenced this pull request Feb 6, 2024
* fix clock resolution detection

* print the delta

* make sure the resolution is usec_t

* use defines for default and max resolution

* fixed wrong calculation

(cherry picked from commit 09db66c)
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.

None yet

3 participants