tools/gen_amalgamated --sdk c currently produces ~12 MB / 290k lines of source. Most of it is dead weight: per-domain trace + config protos and a handful of C++ files that the C ABI under include/perfetto/public/abi/ never references. They're pulled in transitively via the GN dep graph (recurse_in_header_deps walks :zero|cpp even when nothing #includes them) and via cppgen_plugin's [lazy = true] skip not being transitive.
I have a working set of changes that:
- adds
enable_perfetto_minimal_trace_protos (default off, auto-on for --sdk c)
- gates per-domain trace/config/common proto deps behind it
- extends
cppgen_plugin's lazy-import skip to walk transitively
- gates
src/tracing/{console_interceptor,track_event_state_tracker,track_event_legacy}.cc and src/base/{cpu_info,ctrl_c_handler,getopt_compat,subprocess*}.cc (all unreachable from the C ABI)
Result on the C SDK build (no public API change, no impact on --sdk cpp / --sdk all / chromium / Android / standalone):
|
Before |
After |
perfetto_c.{cc,h} |
12.0 MB |
5.6 MB (-54%) |
Stripped .so (-O2 -fvisibility-inlines-hidden) |
2.69 MB |
2.22 MB (-17%) |
clang++ -O2 -c wall time |
37.1 s |
30.1 s (-19%) |
@LalitMaganti @primiano Are we interested in making this improvement? If yes I'll prepare them for review (6 small commits).
tools/gen_amalgamated --sdk ccurrently produces ~12 MB / 290k lines of source. Most of it is dead weight: per-domain trace + config protos and a handful of C++ files that the C ABI underinclude/perfetto/public/abi/never references. They're pulled in transitively via the GN dep graph (recurse_in_header_depswalks:zero|cppeven when nothing#includes them) and viacppgen_plugin's[lazy = true]skip not being transitive.I have a working set of changes that:
enable_perfetto_minimal_trace_protos(default off, auto-on for--sdk c)cppgen_plugin's lazy-import skip to walk transitivelysrc/tracing/{console_interceptor,track_event_state_tracker,track_event_legacy}.ccandsrc/base/{cpu_info,ctrl_c_handler,getopt_compat,subprocess*}.cc(all unreachable from the C ABI)Result on the C SDK build (no public API change, no impact on
--sdk cpp/--sdk all/ chromium / Android / standalone):perfetto_c.{cc,h}.so(-O2 -fvisibility-inlines-hidden)clang++ -O2 -cwall time@LalitMaganti @primiano Are we interested in making this improvement? If yes I'll prepare them for review (6 small commits).