commit | 2789b5bd404d06a4b97fc4d14c798528d4b3886b | [log] [tgz] |
---|---|---|
author | Daniele Di Proietto <ddiproietto@google.com> | Fri Apr 14 09:53:03 2023 +0000 |
committer | Daniele Di Proietto <ddiproietto@google.com> | Fri May 05 14:42:33 2023 +0000 |
tree | f7c05714a2edf270a54e09be7e42ed85140abbca | |
parent | 3f822f4d245fb890e5957c9d70ecdda3be6d37dd [diff] |
tracing_service_impl: Move compression from perfetto_cmd.cc Before this change, trace compression was implemented in perfetto_cmd.cc. This meant that it wasn't possible to use compression with `write_into_file`, because the service would be directly writing the data to a file, without going through perfetto_cmd. With this commit the code that does the compression is moved into the tracing service. Note that compression in the tracing service is only enabled as part of `traced`, it's not enabled in the tracing service in the client library (the compressor is injected with a function pointer). Note that this change might have unexpected behavior when using mismatching versions of perfetto_cmd and tracing_service (both will try to compress or none will). In practice I'm not aware of any use of mismatching versions, so I think it this will not be a problem. The `compress_from_cli` config option can be used to restore the old behavior (both in perfetto_cmd and tracing_service). Here's the change in binary size for various files on android before and after this patch: ``` | Binary | Size before | Size after | | -------------------------------- | ----------- | ---------- | | /system/bin/surfaceflinger | 7445056 | 7445072 | | /system/lib64/libgpumemtracer.so | 801936 | 806088 | | /system/lib64/libperfetto.so | 1124896 | 1125184 | | /system/bin/perfetto | 545176 | 545152 | ``` surfaceflinger and libgpumemtracer statically link the perfetto client SDK. libperfetto.so contains the tracing service. The last point to consider is that this makes the compression ratio a little bit worse when write_into_file is not used. Before this patch, perfetto_cmd was compressing as part of the same stream up to 512 Kb of data. Now, reads from IPC are limited to 32 Kb, so that's how often we have to reset the compression stream. In tested compressing 26 Mb of a sample trace in both configurations and this are the results I got: ``` | Single stream size | Total size | # of compressed packets | | -------------------------------- | ---------- | ----------------------- | | 32 Kb (after this patch) | 9049943 | 574 | | 64 Kb | 8708512 | 337 | | 512 Kb (before this patch) | 8306867 | 50 | ``` Bug: 278884624 Change-Id: Ib777ba5c44930a53b3e95994e768a970822e70a3
Perfetto is a production-grade open-source stack for performance instrumentation and trace analysis. It offers services and libraries and for recording system-level and app-level traces, native + java heap profiling, a library for analyzing traces using SQL and a web-based UI to visualize and explore multi-GB traces.
See https://perfetto.dev/docs or the /docs/ directory for documentation.