Skip to content

Conversation

@Mr0grog
Copy link
Member

@Mr0grog Mr0grog commented Dec 12, 2025

This adds a new MAX_DIFFS_PER_WORKER environment variable that limits the number of diffs performed by a single worker. After a worker process performs this many diffs, it is shut down and replaced with a fresh process.

This is an ugly first cut and needs a lot of cleaning up. It’s probably time to address the longstanding to-do here:

# TODO: we should split out all the management of the executor and diffing
# (so this, get_diff_executor, caller, etc.) into a separate object owned
# by the server so we don't need weird bits checking the server's
# `terminating` state and so that all the parts are grouped together.
async def diff(self, func, a, b, params, tries=2):

This also doesn't really account for things on a per worker basis — it just restarts the pool after DIFFER_PARALLELISM * MAX_DIFFS_PER_WORKER diffs. But newer versions of Python have an API that does this right and which we should eventually switch to when compatible (although it seems like there maybe be some bugs in it: #202 (comment)).

Fixes #202.

@Mr0grog Mr0grog moved this from Inbox to In Progress in Web Monitoring Dec 12, 2025
This adds a new `MAX_DIFFS_PER_WORKER` environment variable that limits the number of diffs performed by a single worker. After a worker process performs this many diffs, it is shut down and replaced with a fresh process.

This is an ugly first cut and needs a lot of cleaning up. It also doesn't really account for things per worker -- it just restarts the pool after DIFFER_PARALLELISM * MAX_DIFFS_PER_WORKER diffs. But newer versions of Python have an API that does this right and which we should eventually switch to when compatible.

Fixes #202.
@Mr0grog Mr0grog force-pushed the 202-retiring-before-you-die-is-better-than-being-reanimated-as-a-zombie-pool branch from b2014e9 to 61ebba3 Compare December 13, 2025 02:17
@Mr0grog
Copy link
Member Author

Mr0grog commented Dec 13, 2025

Rebased to merge release notes cleanly. This is messy, but I’m thinking refactoring diff pool management may be big enough that it should be done in a second followup PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Add options for max diffs before restarting process

1 participant