-
Notifications
You must be signed in to change notification settings - Fork 31k
CI: Track SWC native binary size in PR stats comment #92938
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,32 @@ const collectDiffs = require('./collect-diffs') | |
| const { statsAppDir, diffRepoDir } = require('../constants') | ||
| const { calcStats } = require('../util/stats') | ||
|
|
||
| // Location of the native binary that the workflow copies into the action dir. | ||
| // From src/run/index.js → .github/actions/next-stats-action/native | ||
| const nativeBinaryDir = path.join(__dirname, '../../native') | ||
|
|
||
| // Sum the size of all *.node files in the action's native/ directory. | ||
| async function getSwcBinarySize() { | ||
|
Contributor
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. This might be more valuable if we either break out per-platform or choose one/two to focus on (maybe x86_64 Linux + aarch64 darwin?). The total size is only somewhat meaningful.
Member
Author
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. It's only Linux, since we only build linux |
||
| try { | ||
| const entries = await fs.readdir(nativeBinaryDir) | ||
| let total = 0 | ||
| let found = 0 | ||
| for (const entry of entries) { | ||
| if (!entry.endsWith('.node')) continue | ||
| const stat = await fs.stat(path.join(nativeBinaryDir, entry)) | ||
| if (stat.isFile()) { | ||
| total += stat.size | ||
|
Contributor
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. it would be good to measure the size when it is stripped and when it is gzipped as well |
||
| found++ | ||
| } | ||
| } | ||
| if (found === 0) return null | ||
| return total | ||
| } catch (err) { | ||
| logger(`Unable to measure SWC binary size: ${err.message}`) | ||
| return null | ||
| } | ||
| } | ||
|
|
||
| // Number of iterations for build benchmarks to get stable median | ||
| const BUILD_BENCHMARK_ITERATIONS = 5 | ||
|
|
||
|
|
@@ -57,6 +83,7 @@ async function runConfigs( | |
| let curStats = { | ||
| General: { | ||
| nodeModulesSize: null, | ||
| swcBinarySize: null, | ||
| }, | ||
| } | ||
|
|
||
|
|
@@ -83,6 +110,7 @@ async function runConfigs( | |
| curStats.General.nodeModulesSize = await getDirSize( | ||
| path.join(statsAppDir, 'node_modules') | ||
| ) | ||
| curStats.General.swcBinarySize = await getSwcBinarySize() | ||
| } | ||
|
|
||
| // Run builds for selected bundler(s) and collect stats separately | ||
|
|
||
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.
We could probably test this by adding something like this to the binary cdylib crate: