Repository navigation
hash: measure the table again: Emscripten linked at its optimization level, WASI without debug information - #2
Merged
Conversation
…inked at their optimization level The table of 2026-11-15 was measured on a superproject without webcpp's "link emscripten programs at their compile's level of optimization" (webcpp PR 18), so every Emscripten program was linked at em++'s -O0: space-hkdf_extract_hash2_hmac_sha2_512 was 121,510 bytes, which the same object relinked without -Os gives byte for byte today. Linked at -Os, as the superproject's main now links it, it is 21,083 bytes and libsodium's 24,591, so hkdf_extract over hmac_sha2_512 on Emscripten orders hash2 first by size, and the measure lane failed on main. Measured again with `python3 tools/hash/measure.py --write` on main: every Emscripten size and throughput changes, wasip2's and wasip3's sizes do not, and native's change by 16 bytes in one cell (hkdf over hmac_sha2_256 on BearSSL). The orders that change are Emscripten's: hkdf_extract over hmac_sha2_512 by size (hash2, sodium), and hkdf_expand over hmac_sha2_256 and hkdf over both hmacs by throughput (sodium ahead of hash2, its median now 10.6 to 12.5 percent lower). The default of the smallest profile on Emscripten for hkdf_extract over hmac_sha2_512 becomes hash2. The sizes do not depend on the host: the two Emscripten programs built in a linux/amd64 container with the same Emscripten 6.0.11 are byte-identical to the macOS arm64 ones (same SHA-256). The generated tables of the guide are written again from the new data (tools/hash/doc_tables.py --write).
…ion, whose paths are the host's that built wasi-sdk A WASI program for size carried the DWARF of wasi-sdk's prebuilt libc++, which names the include paths of the machine that built the release: /Users/runner/work/wasi-sdk/... in wasi-sdk 34's macOS archive and /src/src/... in its Linux one. The same program, built from the same objects with the same wasi-sdk, was 1,024 bytes larger on macOS than in a linux/amd64 container (space-hkdf_extract_hash2_hmac_sha2_256 on wasip2: 440,872 and 439,848 bytes), and 58 of the 146 WASI cells differed, by 128 to 2,000 bytes. A WebAssembly order is compared on every host, so a near tie could flip with the host that measures it; and the debug sections were most of each program: that program is 59,161 bytes without them. test/measure/Jamfile links every WASI program with wasm-ld's --strip-debug (<target-os>wasi:<linkflags>-Wl,--strip-debug). Emscripten's link at -Os keeps no debug section already, and natively the size is the stripped executable. Measured again (`python3 tools/hash/measure.py --write`, an idle machine: load averages 10.6 before and 5.5 after on 18 cores): every wasip2 and wasip3 size changes, Emscripten's and native's do not. Without libc++'s debug information, libsodium is smaller than hash2 for hkdf_expand on wasip2 and wasip3 (73,410 and 75,028 bytes over hmac_sha2_256), and for hkdf after BearSSL, so those orders by size, and the default by size of hkdf_expand on WASI, become libsodium's. No throughput order changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The libs/hash half of webcpporg/webcpp#23, which carries the measure.py check.
The measure lane failed on webcpp's main (run 43883027557, job "Own lane (hash, measure)"):
Root cause
-Osgives the committed 121,510 bytes exactly. Linked at-Os, as main does, hash2 is 21,083 bytes and libsodium 24,591, so hash2 is now the smaller one. The Mac reproduces CI's failure message exactly on main./Users/runner/work/wasi-sdk/...in the macOS archive and/src/src/...in the Linux one. The result: 58 of the 146 WASI cells were 128 to 2,000 bytes larger on macOS than in a linux/amd64 container with the same wasi-sdk 34. For example,space-hkdf_extract_hash2_hmac_sha2_256on wasip2 was 440,872 bytes on macOS and 439,848 on Linux. The debug sections were most of each program: that one is 59,161 bytes without them.Fix
test/measure/Jamfilelinks every WASI program with-Wl,--strip-debug. Emscripten's-Oslink keeps no debug section already, and natively the size is the stripped executable.tools/hash/measure.py(--checkand--write) reads each WebAssembly program's custom sections, including every core module and component a wasip2 component nests. It fails, naming each program for size that has a.debug*section. The test came first:test_a_webassembly_program_with_debug_information_fails. RULES now says the .wasm carries no debug information.python3 tools/hash/measure.py --writeon an idle machine (loaded: false), and the guide's generated tables were rewritten withdoc_tables.py --write. Orders that change:Host independence
__FILE__strings of wasi-sdk's libc++abi (fallback_malloc.cpp,private_typeinfo.cpp) in the data section. These are real program bytes, so they cannot be stripped. No order can flip on them: the smallest gap between adjacent backends in any WebAssembly order is 1,212 bytes. Removing the residual would take one host-independent wasi-sysroot on every host, which is a toolchain decision outside this change.Verification
libs/hash/test/measure//measure, from scratch:tools/test/hash_measure_test.py(16 cases) andhash_doc_tables_test.pyok;doc_tables.py --checkok; Pyright clean on both changed files.-a, libs/hash/test and example): native 153 passed, wasip2 151, wasip3 151, Emscripten 118.Remaining: wasi-sdk's libc++ debug information also inflates every webcpp WASI release program. Whether release links should strip it is a separate decision, not made here. bench/'s
doc/measurements.throughput.jsonwas measured before PR 18 as well and was not re-run.🤖 Generated with Claude Code