Description
👋 hi, I work on Stackblitz, where we heavily rely on wasm-bindgen and threads ❤️
However, we're being hit pretty hard by the lack of thread teardown routines. Unlike other use cases, we don't spawn a fixed number of threads. Instead, we spawn workers on demand, roughly corresponding to user-created "processes". This means that a long-running project ends up leaking at least 1MiB of thread stack only [*], without counting TLS, per process 😱
We've perused the open issues and existing discussions (mostly this) and we realize there is not clear runtime model for proper thread support. But we could greatly benefit if wasm-bindgen exposed a helper to clean up the thread stack, even in the most hacky and unstable way. We have done a little experimentation on our side and it doesn't seem like a huge change, we could happily submit a PR.
We understand this is far from an ideal solution, but without something like this, our only option will pretty much be using a private fork 😞
Thoughts?
[*]: though yes, we're looking into reducing the pre-allocated stack size to alleviate the issue.