olvaffe / percetto

Apache License 2.0
19 stars 10 forks source link

how best to handle perfetto::Tracing::Initialize arguments #11

Open batesj opened 3 years ago

batesj commented 3 years ago

@gerddie raised this issue with the current INIT API that once we support a shared library C API it will not work well, because only the first call to init will get to set the config options.

Design alternatives:

  1. Same as perfetto: passed in parameters to percetto_init.
  2. Config file loaded during percetto_init -- if it is found it is used as defaults.
  3. Build option to specify default values.
  4. Update perfetto to handle dynamic changes to these settings to compromise between different options for different libraries. ie: if mesa wants shmem_size_hint_kb of 400 and virglrenderer wants 200, perfetto could dynamically update it to the greater of the two options -- 400.
  5. A combination of the above.
batesj commented 3 years ago

Note that with the current static library design of percetto, this isn't a problem. Mesa and virglrenderer, for example, should have their own percetto instance with their own config. That actually works well because those projects can choose perfetto config options based on their own tracing usage patterns.

  1. Allow overriding perfetto config options via env vars. With the current perfetto SDK design, another option similar to a config file is environment variables that override config options. For an application like crosvm that links against multiple libraries that use perfetto, the system would run it with environment variables that override each necessary perfetto option. This is slightly cleaner than a config file on systems where there are no commonly accessible file paths for all the security contexts where perfetto runs.
batesj commented 3 years ago

Implemented (6) to begin with.