Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Consider removing un-needed memory operation shims

オープン
#44 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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/align8 symbols 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-size memset/memcpy, unrolls the trie loop, and constant-folds strlen on the literal sequences.
  • buf_put's variable-length memcpy lowers directly to a memory.copy instruction 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 into mem.h as static inline and drop the definition from mem.c. Before doing so, build and compare raw + gzipped bundle size against main to 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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bombshell-dev/tty のほかの issue

bombshell-dev/tty の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。