Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not reuse global worker pool for files #84

Merged
merged 6 commits into from
Nov 9, 2024
Merged

Conversation

trowski
Copy link
Member

@trowski trowski commented May 25, 2024

This modifies the parallel driver to create its own internal pool by default, rather than reuse the global worker pool. A specific pool can still be passed to the constructor (though I assume this use is rather rare).

The AMP_WORKER constant is no longer used to prevent the blocking driver from being used. This way, a Task may still use async file access and get the behavior expected.

/cc @azjezz

@trowski trowski requested a review from kelunik May 25, 2024 18:02
src/functions.php Outdated Show resolved Hide resolved
Comment on lines -65 to 54
if (\defined("AMP_WORKER")) { // Prevent spawning infinite workers.
return new BlockingFilesystemDriver;
}

return new ParallelFilesystemDriver;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we prevent infinite ParallelFilesystemDriver instances now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't, so tasks can use async file access. @azjezz mentioned this was an issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But inside the worker we'll spawn another worker now and so on and never actually handle filesystem calls, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No no, FileTask which handles file system calls will use the blocking driver for the call. If the worker executes a user task, then another pool of workers might be spawned. I don't see infinite workers being likely (unless someone executes a Task within a Task, but that would be strange), but each worker having its own set of workers would be a possibility. Since by default we limit the number of workers to 8, the resource usage should still be within reason even on systems without eio or uv.

@trowski trowski merged commit 6c03166 into 3.x Nov 9, 2024
12 checks passed
@trowski trowski deleted the no-global-pool-reuse branch November 9, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants