producer: Batch commit requests to service. Currently, we flush the buffer on every returned chunk or send-patches request, which is causing unnecessary overhead. This change introduces a delay period, during which commit requests are accumulated. When the delay period ends, the buffer is flushed. The next time when a chunk is returned or a patch request is sent, we schedule another delayed flush. If the buffer grows too large or an immediate flush is requested (via SharedMemoryArbiter::FlushPendingCommitDataRequests), we don't wait for the delay period to end and flush immediately. This does not cancel any pending delayed flushes. Because batching can result in accumulated data being dropped at the end of a tracing session, it has been made opt-in. Producers that want to enable it should make sure that they enable asynchronous stopping of data sources and that they call an immediate flush while the async stop lasts. Batching can also aggravate data loss during a producer crash, even with scraping enabled, because the effectiveness of scraping is reduced by unsent batched patches. This will be addressed in https://android-review.googlesource.com/c/platform/external/perfetto/+/1309414 This change is related to https://chromium-review.googlesource.com/c/chromium/src/+/2106176, https://chromium-review.googlesource.com/c/chromium/src/+/2149648 and https://android-review.googlesource.com/c/platform/external/perfetto/+/1309414 Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1029298 Change-Id: I7f8097e5b583412facc6b6d15aadc037a4fd6842
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.