Build the wasm module with -DNDEBUG - #3066
Merged
Merged
Conversation
`rake wasm:build` compiled the parser without `NDEBUG`, so every `RBS_ASSERT`
survived into `rbs_parser.wasm`. The MRI extension already drops them
(ext/rbs_extension/extconf.rb), and the assertions that matter sit on the
hottest paths there are: two per character in `rbs_encoding.c`, one per
character in `rbs_skip`, and five around the constant pool. Each one is an
out-of-line varargs call to `rbs_assert_impl`, which the compiler cannot inline
away, so the cost is paid on every character lexed.
Parsing core/ + stdlib/ (250 files, 4.3MB) through a WASI host, best of 10:
assert build 75.7 ms
NDEBUG build 61.9 ms (-18%)
Measured the same on wasmtime and on V8. The serialized ASTs for all 250 files
are byte-identical between the two builds.
`DEBUG=1 rake wasm:build` keeps the assertions, matching the DEBUG convention
extconf.rb and the prepare_bench / prepare_profiling tasks already use.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012uu4EqN6azBeVjM9F71TUp
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.
rake wasm:buildwas compiling the parser withoutNDEBUG, so everyRBS_ASSERTsurvived intorbs_parser.wasm— unlike the MRI extension, which already drops them inext/rbs_extension/extconf.rb.It was up to 20% slower with
RBS_ASSERTcalls.This adds
-DNDEBUGto the wasm build, withDEBUG=1 rake wasm:buildas the escape hatch for keeping the assertions, matching theDEBUGconventionextconf.rband theprepare_bench/prepare_profilingtasks already use.Measurements
Parsing
core/+stdlib/(250 files, 4.3MB), best of 10, three rounds:-DNDEBUG