Skip to content

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Dec 6, 2023

  • changed default available pool size from 40 to 5, but floating, not just at the start
  • remove explicit <_WasmPThreadPoolSize> from project files
  • set PTHREAD_POOL_SIZE_STRICT=0 which will not throw when we run out of thread pool threads, but it will allocate more.
    • if you are lucky, the pool will always have some loaded threads
    • if you are less lucky, but still your main thread is serving the event loop, threads will be created on demand and used
    • if you block UI event loop, you will eventually run out of the pool and deadlock. This is "sorry, don't do that"
  • replaced emscripten's getNewWorker internal and use it to trigger adding more to the emscripten's thread pool.
  • simplified acquisition and replacements in Module's PThread internal
  • rename WebWorker to JSWebWorker
  • cleanup JSWebWorker
  • add await JavaScriptImports.ThreadAvailable to JSWebWorker so that we are sure that the pthread is ready/loaded
  • remove workers which were used as JSWebWorker from the pool, because they have dirty JS state

@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-VM-threading-mono os-browser Browser variant of arch-wasm labels Dec 6, 2023
@pavelsavara pavelsavara added this to the 9.0.0 milestone Dec 6, 2023
@pavelsavara pavelsavara self-assigned this Dec 6, 2023
@ghost
Copy link

ghost commented Dec 6, 2023

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details
  • set PTHREAD_POOL_SIZE_STRICT=0 which will not throw when we run out of thread pool threads, but it will allocate more.
    • if you are lucky, the pool will always have some loaded threads
    • if you are less lucky, but still your main thread is serving the event loop, threads will be created on demand and used
    • TODO: currently our Xunit runner is not yielding and so it will deadlock
  • changed default available pool size from 40 to 3, but floating, not just at the start
  • replaced emscripten's getNewWorker internal and use it to trigger adding more to the emscripten's thread pool.
  • simplified acquisition and replacements in Module's PThread internal
  • rename WebWorker to JSWebWorker
  • cleanup JSWebWorker
  • add await JavaScriptImports.ThreadAvailable to JSWebWorker so that we are sure that the pthread is ready/loaded
  • adding System.Runtime.InteropServices.JavaScript.Tests as MT smoke test
  • remove explicit <_WasmPThreadPoolSize> from project files
Author: pavelsavara
Assignees: pavelsavara
Labels:

arch-wasm, area-VM-threading-mono, os-browser

Milestone: 9.0.0

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara pavelsavara force-pushed the browser_mt_dynamic_thread_create branch from 2f852a6 to edf8e14 Compare December 12, 2023 11:58
@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara pavelsavara merged commit f6a96fb into dotnet:main Dec 13, 2023
@pavelsavara pavelsavara deleted the browser_mt_dynamic_thread_create branch December 13, 2023 07:55
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-VM-threading-mono os-browser Browser variant of arch-wasm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants