Run score_paths scoring off the event loop to keep heartbeat alive#93
Merged
Conversation
The score_paths worker's scoring job was running almost entirely on the asyncio event loop: the synchronous feature-build loop (LMDB reads + numpy) plus message decompression/compression in get_message/save_message. On large queries this blocked the loop for longer than the 15s heartbeat TTL, so the heartbeat coroutine couldn't refresh its Redis key and the monitor fired false "worker lost" alerts even though the worker was healthy and busy. Convert score_paths to a sync function and run the whole job in a single run_in_executor call on the existing ThreadPoolExecutor, using the sync DB helpers (get_message_sync/save_message_sync). This frees the event loop for the full duration of a scoring job, collapses the previous three executor hops (feature build, MLP, classifier) into one, and also offloads the message compression. save_message_sync is wrapped in a retry loop to preserve the 4-retry durability semantics of the async save_message.
Codecov Report❌ Patch coverage is
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The score_paths worker's scoring job was running almost entirely on the asyncio event loop: the synchronous feature-build loop (LMDB reads + numpy) plus message decompression/compression in get_message/save_message. On large queries this blocked the loop for longer than the 15s heartbeat TTL, so the heartbeat coroutine couldn't refresh its Redis key and the monitor fired false "worker lost" alerts even though the worker was healthy and busy.
Convert score_paths to a sync function and run the whole job in a single run_in_executor call on the existing ThreadPoolExecutor, using the sync DB helpers (get_message_sync/save_message_sync). This frees the event loop for the full duration of a scoring job, collapses the previous three executor hops (feature build, MLP, classifier) into one, and also offloads the message compression. save_message_sync is wrapped in a retry loop to preserve the 4-retry durability semantics of the async save_message.