Making thread-local initialization explicit
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- wasm
調査の方向性
この issue では、ファイル、テスト、実装のエントリーポイントが指定されていません。まず提案に既にある thread-local-global とスレッドごとのインスタンス化モデルを確認し、その後、必要な API と trap のセマンティクスを決定してください。完了とは、明示的なインスタンス化の動作が、インスタンス、スレッド、imports、exports について一貫して仕様化されていることを意味します。
索引モデルが issue の本文から書いたものです。
説明
One of the biggest problems identified with thread-local globals so far is the complexity and cost of ensuring they are initialized before they are used. One option we've considered is eagerly initializing the TLS for every instance when a new thread is created and eagerly creating the TLS for every thread when a new instance is created. This obviously scales very poorly. The other option we've considered is initializing TLS lazily upon entering a particular instance on a particular thread for the first time, but that would slow down all indirect calls because they would have to check whether they are crossing an instance boundary and need to initialize TLS.
I recently developed an idea for another option, which is to give up on ensuring that thread-local storage is available by the time it is accessed, and instead trap if it has not been explicitly initialized yet for the current thread. This was always going to be what happened when you called a thread-bound imported JS function before binding it on the current thread, so the new idea is to extend that pattern to thread-local globals as well. This semantics means that we need neither expensive eager initialization nor expensive lazy initialization, and ideally the initialization check on access could be made fast by using a trap handler.
The API for this explicit instantiation could be attached to some kind of shareable handle to a Module/Instance hybrid. This handle would be vended by a WebAssembly.Instance and could provide access to the shared exports of the instance on any thread, but it would only provide access to the unshared exports (if any) on a thread once it has been instantiated with the unshared and thread-local imports on that thread. The TLS would be allocated and initialized as part of this per-thread instantiation.
This would be essentially committing to the instance-per-thread model, at least as far as TLS is concerned. My hope is that this will be acceptable in the component model because the thread.spawn builtin will be able to identify any necessary thread-local imports from the thread-local reflection of the module/instance graph and can be specified as invoking the embedder API for doing the per-thread instantiation.
- 主要言語
- WebAssembly
- スター
- 98
- フォーク
- 7
- 平均マージ
- 1日 20時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
WebAssembly/shared-everything-threads のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
WebAssembly/shared-everything-threads#119 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
WebAssembly/shared-everything-threads#114 · コメント 7 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
WebAssembly/shared-everything-threads#105 · コメント 6 件 ·
WebAssembly/shared-everything-threads の issue をすべて見る
似ている issue
-
agent:WSL bug linux LOW
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
leanprover/lean4#15683 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
bytecodealliance/rustix#1703 ·
メンテナーはふだん 3 日以内に返信