-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Support preallocated pthread & wasm worker from blob #22565
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,10 +98,20 @@ var LibraryPThread = { | |
}, | ||
initMainThread() { | ||
#if PTHREAD_POOL_SIZE | ||
var pthreadPoolSize = {{{ PTHREAD_POOL_SIZE }}}; | ||
// Start loading up the Worker pool, if requested. | ||
while (pthreadPoolSize--) { | ||
PThread.allocateUnusedWorker(); | ||
preallocateWorkers = () => { | ||
var pthreadPoolSize = {{{ PTHREAD_POOL_SIZE }}}; | ||
// Start loading up the Worker pool, if requested. | ||
while (pthreadPoolSize--) { | ||
PThread.allocateUnusedWorker(); | ||
} | ||
}; | ||
#if expectToReceiveOnModule('mainScriptUrlOrBlobPromise') | ||
if (Module['mainScriptUrlOrBlobPromise']) { | ||
Module['mainScriptUrlOrBlobPromise'].then(preallocateWorkers); | ||
} else | ||
#endif | ||
{ | ||
preallocateWorkers(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about instead updating e.g.:
This would avoid the new/extra closure. |
||
#endif | ||
#if !MINIMAL_RUNTIME | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,7 +182,7 @@ if (ENVIRONMENT_IS_WASM_WORKER | |
'mem': wasmMemory, | ||
#else | ||
'wasm': wasmModule, | ||
'js': Module['mainScriptUrlOrBlob'] || _scriptName, | ||
'js': URL.createObjectURL(Module["mainScriptUrlOrBlob"]) || _scriptName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is fix for the case when Can we add a test for this? And perhaps make it a separate PR and it seems somewhat orthogonal. |
||
'wasmMemory': wasmMemory, | ||
#endif | ||
'sb': stackLowestAddress, // sb = stack bottom (lowest stack address, SP points at this when stack is full) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is
mainScriptUrlOrBlobPromise
? I don't see that anywhere in the existing source code? Is the idea that someone could add this to-sINCOMING_JS_MODULE_API
? If so I wonder if we should document it somewhere.If that creation of the main thread needs to be delayed until the
mainScriptUrlOrBlob
is ready can't this be done via existing mechanisms? For example, any of these approaches:addRunDependency
? (this one might not work since I'm not sure it blocksinitMainThread
.