Consider removing un-needed memory operation shims
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 50/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- c, wasm
調査の方向性
src/mem.c と mem.h から始め、続いて input_init と buf_put の現在の呼び出し箇所を、-O2 -mbulk-memory --gc-sections を使ったビルドに対して監査します。raw の clayterm.wasm と gzip 圧縮した clayterm.wasm のサイズを、main と比較し、wc -c と gzip -c | wc -c を使って測定します。各 shim について、保持するか削除するかの判断が文書化され、その判断がビルドとサイズ測定によって裏付けられていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
src/mem.c currently provides memcpy, memset, strlen, and align8 as freestanding-wasm shims, and PR #32 proposes adding a memmove shim alongside them. Investigation of the linked clayterm.wasm shows that none of these functions survive into the final binary under the current -O2 -mbulk-memory --gc-sections build:
- A non-stripped build links cleanly with zero
memcpy/memset/strlen/align8symbols in the output. input_init— the heaviest caller, containing the trie-building loop over the static cap tables — compiles to zero call instructions. LLVM inlines every constant-sizememset/memcpy, unrolls the trie loop, and constant-foldsstrlenon the literal sequences.buf_put's variable-lengthmemcpylowers directly to amemory.copyinstruction thanks to-mbulk-memory.
In other words, the shims exist purely as a safety net for code the optimizer fails to lower. And if the optimizer fails to lower it, then that is something that should be surfaced, not silently cause our performance to degrade.
Possible Approach
Audit each shim against current call sites and decide case-by-case:
align8— trivial(n + 7) & ~7. Best candidate for a free win: move intomem.hasstatic inlineand drop the definition frommem.c. Before doing so, build and compare raw + gzipped bundle size againstmainto confirm the inline expansion does not regress size (it shouldn't — every call site is already inlined — but it is worth measuring rather than assuming).memset/memcpy— every current call is constant-size or variable-length-with--mbulk-memory-lowering, so both are dead in the linked binary. Keep as a safety net or drop entirely; if dropped, document the requirement that contributors avoid call patterns the optimizer cannot lower.strlen— only foldable because the cap tables are statically initialized literals. A future call on a runtime string (e.g.buf_str(b, user_input)) would re-introduce the link dependency. Lowest-risk shim to keep.memmove(PR #32) — reconsider in light of the above. If we keep the others as defensive shims, merging this one is consistent; if we trim, this one should not land without a real call site.
Decisions should be backed by before/after wc -c and gzip -c | wc -c on clayterm.wasm.
- 主要言語
- TypeScript
- スター
- 42
- フォーク
- 2
- 平均マージ
- 2日 5時間
- マージ済み PR(30日)
- 12
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bombshell-dev/tty のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
bombshell-dev/tty#61 · リアクション 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
bombshell-dev/tty#129 ·
-
question
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
bombshell-dev/tty#112 ·
-
enhancement high priority
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
bombshell-dev/tty#83 · コメント 2 件 ·
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
bombshell-dev/tty#82 ·
bombshell-dev/tty の issue をすべて見る
似ている issue
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
Crush オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
ElementsProject/cln-application#167 · コメント 1 件 · リアクション 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Quantco/pnpm-licenses#17 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100