Skip to content

perf: reduce prebuilt binary size - #415

Merged
IlyasShabi merged 2 commits into
mainfrom
ishabi/reduce-size
Sep 18, 2026
Merged

IlyasShabi merged 2 commits into
mainfrom
ishabi/reduce-size

Conversation

@IlyasShabi

Copy link
Copy Markdown

What does this PR do?:
Adds size reduction flags to binding.gyp in order to drop debug info, hide symbol visibility, and enable dead-code stripping.

  • macOS binaries go from 214,624 B to 184,768 B (−14%).
  • Linux and Windows gain from the same flags.
  • Across all 63 prebuilds that's roughly 15.5 MB → 13.5 MB.

The symbol table is deliberately kept so crash reports still show function names. Only the export table shrinks, which nothing reads at runtime. Sanitizer builds are excluded.

Motivation:
prebuilds/ is 15.5 MB of the package's size, and every dd-trace-js user downloads it. A chunk of that is debug info and exported symbols nothing uses.

@github-actions

Copy link
Copy Markdown

Overall package size

Self size: 2.61 MB
Deduped: 3.31 MB
No deduping: 3.31 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | pprof-format | 2.3.1 | 504.33 kB | 504.33 kB | | source-map | 0.8.0 | 185.66 kB | 185.66 kB | | node-gyp-build | 4.8.4 | 13.86 kB | 13.86 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@IlyasShabi IlyasShabi added the semver-patch Bug or security fixes, mainly label Sep 17, 2026
@IlyasShabi
IlyasShabi marked this pull request as ready for review September 17, 2026 12:15
szegedi
szegedi previously approved these changes Sep 17, 2026

@szegedi szegedi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and nice reduction.

Comment thread binding.gyp
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO',
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
'DEAD_CODE_STRIPPING': 'YES', # -dead_strip

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, can we know what dead code is being stripped away? There might be an opportunity to throw it out of source code as well. Of course, if it's not globally dead code but just code that's inactive in particular targets then that's obviously a different story…

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well keeping the flag is about now and later:

  • the last commit removes the one dead signature it surfaced and the rest is the case you guessed (NAN header templates).
  • It means any dead code we introduce stops shipping in the binaries automatically.

@IlyasShabi
IlyasShabi merged commit 30148eb into main Sep 18, 2026
70 checks passed
@IlyasShabi
IlyasShabi deleted the ishabi/reduce-size branch September 18, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-patch Bug or security fixes, mainly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants