-
Notifications
You must be signed in to change notification settings - Fork 82
perf(bundle-source): cut multi-entry agoric bundling time and add detailed profiling #3099
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
turadg
wants to merge
10
commits into
master
Choose a base branch
from
codex/bundle-source-profiling
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,009
−373
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4442760
feat(bundle-source): add opt-in chrome trace profiling
turadg dd9dcf7
feat(bundle-source): add trace merge and summary tool
turadg badc251
feat(bundle-source): add agoric source-spec registry bundling tool
turadg 613e241
feat(bundle-source): add profile-agoric-bundling tool
turadg 1fb51b7
chore(bundle-source): render profile summary with console.table
turadg c83e404
feat(profiling): add compartment-mapper phase spans
turadg b6c2e7e
feat(profiling): add compression and babel stage spans
turadg 93a6674
fix(profiling): await node-modules parent span timing
turadg 8050eb9
feat(profiling): add critical-path metrics and fix module-source span…
turadg b03648b
perf(bundle-source): speed up multi-entry bundling and add profiling …
turadg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,6 +119,64 @@ map for every physical module. | |
| It is not yet quite clever enough to collect source maps for sources that do | ||
| not exist. | ||
|
|
||
| ## Profiling | ||
|
|
||
| `bundle-source` can emit Chrome trace files for performance analysis. | ||
| This works for programmatic usage and CLI usage, including builds in larger | ||
| repos like `agoric-sdk`. | ||
|
|
||
| Enable with environment variables: | ||
|
|
||
| ```console | ||
| ENDO_BUNDLE_SOURCE_PROFILE=1 \ | ||
| ENDO_BUNDLE_SOURCE_PROFILE_DIR=/tmp/bs-profiles \ | ||
| yarn bundle-source app.js > /tmp/app-bundle.json | ||
| ``` | ||
|
|
||
| Each bundle call writes one `*.trace.json` file. Open these in Chrome tracing | ||
| tools or convert for Speedscope. | ||
|
|
||
| You can also control profiling in code: | ||
|
|
||
| ```js | ||
| await bundleSource('program.js', { | ||
| profile: { | ||
| enabled: true, | ||
| traceDir: '/tmp/bs-profiles', | ||
| // or traceFile: '/tmp/specific.trace.json' | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| Environment variables: | ||
| - `ENDO_BUNDLE_SOURCE_PROFILE`: enable profiling when truthy (`1`, `true`, `yes`, `on`) | ||
| - `ENDO_BUNDLE_SOURCE_PROFILE_DIR`: output directory for generated trace files | ||
| - `ENDO_BUNDLE_SOURCE_PROFILE_FILE`: explicit output file for a single run | ||
| - `ENDO_BUNDLE_SOURCE_PROFILE_STDERR`: if truthy, prints each generated trace path to stderr | ||
|
|
||
| Merge and summarize many profile traces: | ||
|
|
||
| ```console | ||
| yarn workspace @endo/bundle-source trace:merge -- /tmp/bs-profiles | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this actually specific to bundle-source, or e.g. sufficiently general for arbitrary trace composition? |
||
| ``` | ||
|
|
||
| This generates: | ||
| - `merged.trace.json` for trace viewers. | ||
| - `summary.json` with aggregate span statistics. | ||
| - `summary.md` with a top spans table by total duration. | ||
|
|
||
| Profile bundling all `source-spec-registry.js` entries from an `agoric-sdk` | ||
| checkout using the current checkout's `bundle-source`: | ||
|
|
||
| ```console | ||
| yarn workspace @endo/bundle-source profile:agoric-bundling -- \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question about this tool. |
||
| --agoric-sdk-root /opt/agoric/agoric-sdk \ | ||
| --out-dir /tmp/profile-agoric-bundling | ||
| ``` | ||
|
|
||
| The tool writes bundles, raw traces, merged trace, and summary files to | ||
| `--out-dir`, and prints a top-spans summary table at the end. | ||
|
|
||
| ## `moduleFormat` explanations | ||
|
|
||
| <a id="getexport-moduleformat"></a> | ||
|
|
||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| export type { | ||
| BundleProfilingOptions, | ||
| BundleOptions, | ||
| BundleSource, | ||
| BundleSourceResult, | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍