Skip to content

Reduce amalgamated C SDK source size #5799

@dreveman

Description

@dreveman

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions