Skip to content

Conversation

josephnoir
Copy link
Contributor

Motivation

NIO’s event loop can emit metrics. Currently, this includes the start time (i.e. when the loop started working) and the number of tasks which were executed in that tick.

It would be useful to collect the time the loop tick ended and the length of time the loop was asleep before starting the tick.

Modifications

The event loop has a new property to track the time between runs. The tick info collects two new values:

  • The time the loop finished: the end-time.
  • The time since the last run: the sleep time.

For the first run, the sleep time is the time since the event loop was created.

Result

The new metrics are available for collection.

Motivation:

NIO’s event loop can emit metrics. Currently, this includes the start time (i.e. when the loop started working) and the number of tasks which were executed in that tick.

It would be useful to collect the time the loop tick ended and the length of time the loop was asleep before starting the tick.

Modifications:

The event loop has a new property to track the time between runs. The tick info collects two new values:
* The time since the last run.
* The time the loop finished.

Result:

The new metrics are available for collection.
@glbrntt glbrntt added the 🆕 semver/minor Adds new public API. label Jun 16, 2025
Copy link
Contributor

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a fix for a comment but otherwise this looks good

Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lovely patch @josephnoir, thank you!

@Lukasa Lukasa enabled auto-merge (squash) June 16, 2025 13:50
@Lukasa Lukasa disabled auto-merge June 16, 2025 13:51
Co-authored-by: George Barnett <[email protected]>
@glbrntt glbrntt merged commit 357955a into apple:main Jun 16, 2025
41 checks passed
@josephnoir josephnoir deleted the loop-tick-info branch June 16, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants