[WIP] Implement Pthread Manager Worker for synchronous thread creation#26979
Open
sbc100 wants to merge 1 commit into
Open
[WIP] Implement Pthread Manager Worker for synchronous thread creation#26979sbc100 wants to merge 1 commit into
sbc100 wants to merge 1 commit into
Conversation
This change introduces a dedicated 'Pthread Manager' worker that acts as an intermediary for managing the lifecycle of pthread workers. By moving the responsibility of spawning and managing workers to a dedicated manager worker, we enable synchronous pthread creation on the main browser thread even when it is blocked (e.g. during a join or futex wait). This is because the manager worker and its nested child workers can be started by the browser independently of the main thread's event loop. Key changes: - Add PTHREAD_MANAGER setting to enable this new mode. - Update shell.js and parseTools.mjs to detect and support the manager environment. - Update libpthread.js to spawn the manager worker and proxy thread creation requests to it. - Update runtime_pthread.js with logic to handle the manager worker's responsibilities: spawning, terminating, and relaying messages for child pthreads. - Ensure the manager worker is fully initialized before the main application starts using addRunDependency. Fixes: emscripten-core#18633
Collaborator
Author
Collaborator
Author
|
Kind of an interesting approach that gemini took here, which is to create to have the pthread-manager running the same JS file. I think this has some advantages in that we can keep the worker spawning code in place where it can run both in manager and non-manager mode. I also like that avoids adding an additional file (e.g. The alternative would be to embed some kind of |
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.
[WIP] - Gemini Created initial PR
This change introduces a dedicated 'Pthread Manager' worker that acts as an intermediary for managing the lifecycle of pthread workers.
By moving the responsibility of spawning and managing workers to a dedicated manager worker, we enable synchronous pthread creation on the main browser thread even when it is blocked (e.g. during a join or futex wait). This is because the manager worker and its nested child workers can be started by the browser independently of the main thread's event loop.
Key changes:
Fixes: #18633