Repository navigation
Conversation
Since emscripten-core#28144, every C define in `struct_info.json` is added to `LibraryManager.library` as three entries (`$FOO`, `$FOO__const`, and `$FOO__internal`). Adding hundreds more constants to `struct_info.json` (as in emscripten-core#28199) would otherwise incur two compile-time performance costs in `compiler.mjs`: 1. In `--symbols-only` mode we only need to discover transitive dependencies on native symbols. As JS library functions replace magic numbers with `struct_info.json` constants, `addImplicitDeps` (`src/jsifier.mjs`) would otherwise record every referenced constant in `__deps` and repeatedly traverse them in `getTransitiveDeps`. Skipping `__const` symbols in `--symbols-only` mode avoids this work. 2. Each `struct_info.json` constant adds three keys to `LibraryManager.library`, which is iterated over in multiple passes that call `isDecorator` (`src/utility.mjs`) on every key. Using `lastIndexOf('__')` and a `Set` lookup instead of `decoratorSuffixes.some` with `endsWith` avoids scanning all 15 decorator suffixes for every key in the library. See: emscripten-core#28199
Collaborator
Author
|
I'd like to land this before #28199 |
There was a problem hiding this comment.
Code Review
This pull request optimizes dependency resolution and decorator suffix checks. In src/jsifier.mjs, a check is added to skip implicit dependencies when symbolsOnly is active and a constant variant of the dependency exists. In src/utility.mjs, the isDecorator function is optimized by converting the decoratorSuffixes array into a Set and checking the suffix using lastIndexOf instead of iterating with some. There are no review comments, and I have no feedback to provide.
sbc100
enabled auto-merge (squash)
November 7, 2026 03:49
This branch has not been deployed
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.
Since #28144, every C define in
struct_info.jsonis added toLibraryManager.libraryas three entries ($FOO,$FOO__const, and$FOO__internal). Adding hundreds more constants tostruct_info.json(as in #28199) would otherwise incur two compile-time performance costs incompiler.mjs:In
--symbols-onlymode we only need to discover transitive dependencies on native symbols. As JS library functions replace magic numbers withstruct_info.jsonconstants,addImplicitDeps(src/jsifier.mjs) would otherwise record every referenced constant in__depsand repeatedly traverse them ingetTransitiveDeps. Skipping__constsymbols in--symbols-onlymode avoids this work.Each
struct_info.jsonconstant adds three keys toLibraryManager.library, which is iterated over in multiple passes that callisDecorator(src/utility.mjs) on every key. UsinglastIndexOf('__')and aSetlookup instead ofdecoratorSuffixes.somewithendsWithavoids scanning all 15 decorator suffixes for every key in the library.See: #28199