Virtual helm merge: offload CPU-bound merge to thread pool to unblock async event loop #35
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Performance Issue
The
_merge_helm_indexesfunction is a CPU-bound operation (YAML parse + URL rewrite + dedup + YAML dump) called directly inside an async route handler. For a 19-member virtual repo, this took 38.5 seconds of wall time, blocking the entire uvicorn event loop for that duration.During this time no other requests can be served on that worker.
Fix
Wrap the synchronous merge call in
asyncio.get_event_loop().run_in_executor(None, ...)(orasyncio.to_threadin Python 3.9+) so it runs in a thread pool without blocking the event loop:This is independent of issue #34 (CSafeLoader) and should be applied regardless — even a fast merge deserves not to block the event loop.
Expected Impact
Other requests continue to be served while a large virtual merge runs. No regression for small merges.