Fix: More accurate heartbeat Interval #3072
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma
Tick the checkbox if you understand [x]:
Description
Fixes #3058
Previously, we
await
on all the async operations in a beat before scheduling the next beat, which means that any blocking operation and timeout will count towards the interval of the next beat. This will drastically increase the duration for long timeouts, and lead to inconsistent beat intervals.A very simple fix is to schedule the next beat right at the start, so no other operations can affect the accuracy. This gets the beat interval accuracy down to 5-15ms on a
Ryzen 5 5600x
, which I think the precise ms will depend on CPU load.Special handling is added for the push monitor. If you call the Push url faster than your set Interval, this will not solve the issue, but I think it's out of scope for this PR.
Type of change
Please delete any options that are not relevant.
Checklist
(including JSDoc for methods)
Screenshots (if any)