Skip to content

Prototype module splitting analysis using relocations #24485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dschuff
Copy link
Member

@dschuff dschuff commented Jun 4, 2025

This is a prototype script implementing analysis for module splitting using the
symbol table and relocations.
It builds a dependence graph that includes all function and data symbols
(as defined in the symbol table when linking with the --emit-relocs flag)

Then, given a list of functions to use as the entry points to a module,
it finds the list of functions that are reachable from the module entry
points but not reachable from main (except via paths that pass through
the module entry points; this alllows for the case where module
entry points are themselves reachable from main).

It has an alternate mode where an 'anchor' function can be specified
to exclude functions reachabe from the anchor rather than main; and
a utility to print all paths that reach a specified function without
going through the module entry points (for understanding why a
particular function is being retained in the main module).

All of this is still an experimental prototype, but it demonstrates
concept, and with a little massaging of the output, the list of
functions could be fed directly to the current version of wasm-split.
(This has not been tested though).

This is a prototype script implementing analysis for module splitting using the
symbol table and relocations.
It builds a dependence graph that includes all function and data symbols
(as defined in the symbol table when linking with the --emit-relocs flag)

Then, given a list of functions to use as the entry points to a module,
it finds the list of functions that are reachable from the module entry
points but not reachable from main (except via paths that pass through
the module entry points; this alllows for the case where module
entry points are themselves reachable from main).

It has an alternate mode where an 'anchor' function can be specified
to exclude functions reachabe from the anchor rather than main; and
a utility to print all paths that reach a specified function without
going through the module entry points (for understanding why a
particular function is being retained in the main module).

All of this is still an experimental prototype, but it demonstrates
concept, and with a little massaging of the output, the list of
functions could be fed directly to the current version of wasm-split.
(This has not been tested though).
@dschuff
Copy link
Member Author

dschuff commented Jun 4, 2025

@aheejin it's still a bit rough and probably should be refactored further if we want to have this longer-term in Emscripten. But it shows the idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant