cylc / cylc-uiserver

A Jupyter Server extension that serves the cylc-ui web application for monitoring and controlling Cylc workflows.
https://cylc.org
GNU General Public License v3.0
15 stars 18 forks source link

async: switch to uvloop #545

Open oliver-sanders opened 8 months ago

oliver-sanders commented 8 months ago

uvloop is a fast (C) replacement for the built-in asyncio event loop (Python) that uses the libuv event loop.

Basically it makes asyncio go faster so should make async code more responsive. As the Cylc codebase becomes increasingly async this switch will help Cylc efficiency.

Two line change (+ one new dependency).

See also https://github.com/cylc/cylc-flow/issues/4852

The results of profiling this problematic workflow revealed that the asyncio.ensure_future method was consuming a reasonable amount of CPU. It's likely that uvloop will have lower overheads for these operations.

oliver-sanders commented 8 months ago

Turns out the large number of async tasks was the result of a recursive async routine.

https://github.com/cylc/cylc-uiserver/pull/548 turns this into an iterative routine bypassing the issue.