MagicStack / uvloop

Ultra fast asyncio event loop.
Apache License 2.0
10.46k stars 550 forks source link

feat(uvloop): Support event loop utilization queries #579

Open cphoward opened 1 year ago

cphoward commented 1 year ago

This change seeks to expose libuv's internal uv_metrics_idle_time to permit users to tune their applications. This change is inspired by Nodejs' internalEventLoopUtilization.

The heart of this change is:

def _event_loop_utilization(self):
    """Returns idle and active time in milliseconds and the percentage of
    time the event loop is active
    """

    ...

    return idle, active, utilization