Repository navigation
v0.0.1-beta.9: Merge pull request #116 from goesm-dev/claude/project-thread-e8tcbc
Pre-release
Pre-release
·
43 commits
to main
since this release
Tagged on 2026-10-30. Changes since v0.0.1-beta.8: v0.0.1-beta.8...v0.0.1-beta.9.
Bundle size
- A Cloudflare Worker serving one Connect service with connect-go bundles to 1.9 MB minified (457 KB gzipped) instead of 4.5 MB (1.18 MB gzipped), imports in 210 ms instead of 570 ms on Node and answers a unary call in 215 µs instead of 340 µs (
testdata/usecases/worker,TestUseCaseWorker):- Package variable initializers and
initfunctions with no effect besides computing their variables are left out when reachable code does not use those variables: net/http's TLS defaults, crypto/tls's tables, nistec's P-256 table and x/text's normalization tables kept TLS, X.509 and elliptic curves. - The self-tests of
crypto/internal/fips140, which run only in FIPS 140 mode, no longer keep the hashes, AES and the key derivations through theinitfunctions that pass them. - Only the entry packages are roots of reachable code: the other packages of the module count for what the entries use, so a server leaves out the client of its generated connect-go package, with net/http's client.
- Reflection's
MethodByNamewith a constant name keeps the methods of that name only of the types stored in interface values, as Go's linker does: protobuf's descriptor formatting callingGetkepthttp.Client.Get.
- Package variable initializers and
- The same Worker bundles to 1.70 MB minified (413 KB gzipped):
- A program that serves requests only through
fetchHandlerno longer stores a*http.Serverin an interface value, whose type descriptor kept crypto/tls, crypto/x509 and math/big for reflection. - The method table of a type that reachable code never stores in an interface value is empty: no type assertion, interface call or reflection looks it up, and the signatures of its methods kept the types they mention.
- The method table of an unnamed struct type with promoted methods is set up in a pure initializer, so that bundlers drop the type with the methods it keeps when nothing uses it: encoding/json/v2's wrappers of
Marshalerand the like were always kept. - Initializers of the form
var x, _ = f()with no effect besides computingxare left out when reachable code does not usex, as single-value ones are: edwards25519's base points.
- A program that serves requests only through
- The same Worker bundles to 1.52 MB minified (369 KB gzipped):
encoding/json'sMarshalandUnmarshal, for the values the runtime does not handle itself, run the encoder and decoder of encoding/json's own implementation (GOEXPERIMENT=nojsonv2), changed to return what Go 1.27's default, json v2 with v1 options, returns: the same errors, partial results, map keys, struct tag names and output. json v2, jsontext and their tables are left out (the json code of the Worker shrinks from about 190 KB to 47 KB), unless the program declares a method namedMarshalJSONToorUnmarshalJSONFrom, which only json v2 calls.testdata/programs/jsonlegacycompares 5,000 random cases with native Go.
Fixes
reflect.Type'sStringof an unnamed struct type shows the fields' tags, as Go does (struct { F int "json:\"f\"" }), and isstruct {}for an empty one.
Blocking analysis
- Blocking is decided again for the code reachable from the entries: code that never runs does not make other code async. In the Worker, the
io.Pipeof connect-go's and net/http's clients madeio.Reader'sReadblock, and through protobuf'sFormatmethods everyfmt.Sprintfandfmt.Errorf.
日本語
2026-10-30 にタグを付けました。v0.0.1-beta.8 からの差分は v0.0.1-beta.8...v0.0.1-beta.9 で確認できます。
バンドルサイズ
- connect-go で Connect のサービスを 1 つ提供する Cloudflare Worker のバンドルは、minify 後 4.5 MB (gzip で 1.18 MB) から 1.9 MB (gzip で 457 KB) になりました。Node での import は 570 ms から 210 ms に、unary 呼び出しの応答は 340 µs から 215 µs になりました (
testdata/usecases/worker、TestUseCaseWorker)。- 変数の計算以外に効果を持たないパッケージ変数の初期化式と
init関数は、到達可能なコードがその変数を使わなければ出力しません。net/http の TLS の既定値、crypto/tls の表、nistec の P-256 の表、x/text の正規化の表が、TLS、X.509、楕円曲線を残していました。 - FIPS 140 mode でだけ実行する
crypto/internal/fips140の自己テストが、それを渡すinit関数を通じてハッシュ、AES、鍵導出を残すことはなくなりました。 - 到達可能なコードの起点は entry パッケージだけになりました。モジュールのほかのパッケージは entry が使う部分だけを数えるので、サーバーは生成された connect-go のパッケージのクライアントと net/http のクライアントを含みません。
- 引数が定数の reflection の
MethodByNameは、interface の値に格納される型のその名前のメソッドだけを残すようになりました。Go のリンカーと同じ扱いです。protobuf の descriptor の整形がGetを呼ぶため、http.Client.Getが残っていました。
- 変数の計算以外に効果を持たないパッケージ変数の初期化式と
- 同じ Worker のバンドルは、minify 後 1.70 MB (gzip で 413 KB) になりました。
fetchHandlerだけでリクエストを処理するプログラムは、*http.Serverを interface の値に格納しなくなりました。その型記述子が、reflection のために crypto/tls、crypto/x509、math/big を残していました。- 到達可能なコードが interface の値に格納しない型のメソッド表は空になりました。型アサーション、interface 経由の呼び出し、reflection のいずれもその表を参照しません。メソッドのシグネチャが、そこに現れる型を残していました。
- 埋め込みによるメソッドを持つ名前のない struct 型のメソッド表は、副作用のない初期化式の中で設定するようになりました。その型を使うコードがなければ、バンドラーは型とメソッドをまとめて削除します。encoding/json/v2 の
Marshalerなどのラッパーが常に残っていました。 var x, _ = f()の形の初期化式も、xの計算以外に効果を持たず、到達可能なコードがxを使わなければ、値が 1 つの初期化式と同じく出力しません。edwards25519 の基点が残っていました。
- 同じ Worker のバンドルは、minify 後 1.52 MB (gzip で 369 KB) になりました。runtime が自身で処理しない値の
encoding/jsonのMarshalとUnmarshalは、encoding/json 自身の実装 (GOEXPERIMENT=nojsonv2) の encoder と decoder で処理するようになりました。Go 1.27 の既定である json v2 を v1 の option で使った場合と同じ結果を返すよう変えてあり、エラー、途中までの結果、map の key、struct tag の名前、出力が一致します。json v2、jsontext とその表は出力しません (Worker の JSON のコードは約 190 KB から 47 KB になりました)。ただし、json v2 だけが呼ぶMarshalJSONToかUnmarshalJSONFromという名前のメソッドを宣言するプログラムは json v2 を使います。testdata/programs/jsonlegacyが 5,000 件のランダムな例で native Go と比べます。
修正
- 名前のない struct 型の
reflect.TypeのStringは、Go と同じく field の tag を表示するようになりました (struct { F int "json:\"f\"" })。空の struct ではstruct {}です。
ブロッキング解析
- entry から到達可能なコードについて、block するかどうかを判定し直すようになりました。実行されないコードが他のコードを async にすることはありません。この Worker では、connect-go と net/http のクライアントが使う
io.Pipeのためにio.ReaderのReadが block し、protobuf のFormatメソッドを通じてすべてのfmt.Sprintfとfmt.Errorfが async になっていました。