Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: relax requirements for emitting clock snapshots #1000

Open
dreveman opened this issue Feb 1, 2025 · 4 comments
Open

feature: relax requirements for emitting clock snapshots #1000

dreveman opened this issue Feb 1, 2025 · 4 comments

Comments

@dreveman
Copy link

dreveman commented Feb 1, 2025

ClockSnapshot packet currently must be emitted before the custom clock is referred to by any TracePacket written by the same TraceWriter

Removing this requirement makes custom clocks easier to use and enables the use-case described below.

Cycle accurate simulator

Cycle accurate simulators advance one or more cycle counters internally when executing workloads. The cycle number is technically the clock that is used to determine performance and what the user of the simulator cares about. This cycle counter doesn't map to the trace time in a predetermined way. The simulator might take a long time to simulate something that takes only a cycle on real hardware, and a short time to simulate something that is really expensive on real hardware. Being able to visualize simulator work based on the cycle count allows perfetto to be used instead of alternative tools to visualize workloads running on simulators. It's also allowing the work to be connected to host side events, which makes it much easier to understand the overall flow of an application.

We need to map events that uses the cycle count to the trace clock. Custom clocks works well except for the requirement that clock snapshots needs to be emitted before track events referring to the clock. The problem is that we don't know how what the unit multiplier for the cycle clock is until the interval that we want to map to trace time has completed. Being able to emit clock snapshots when the interval ends solves this problem.

Alternatives

  1. Manually collect all events in the app and emit them at the end of the "interval". This puts a lot of burden on the application and can result in a large increase in memory usage as we can't flush when desirable and significantly impact application performance.
  2. Simply use nanos as cycles and require the user to zoom in and be aware of this assumption.
@LalitMaganti
Copy link
Collaborator

I've commented on the patch but basically we need to

  1. to keep track of only the packets with the missing clock id
  2. inform the sorter that you need to do a full sort

@dreveman
Copy link
Author

dreveman commented Feb 5, 2025

I've commented on the patch but basically we need to

  1. to keep track of only the packets with the missing clock id
  2. inform the sorter that you need to do a full sort

Yes, I saw your comment. I looked at the sorting code in more detail yesterday so I understand that better now and you're comment and suggestion makes sense. I'll update the patch as suggested asap.

@dreveman
Copy link
Author

@dreveman dreveman reopened this Feb 24, 2025
@dreveman
Copy link
Author

Latest version of patch that was merged works with some of the conversion tools and passes the added unit tests but doesn't fully work with the UI. This is because events that are deferred to EOF will be dropped by the trace processor as it currently Flush, which implies forced sorting and extraction of events just before calling NotifyEndOfFile().

https://android-review.googlesource.com/c/platform/external/perfetto/+/3505773 is a WIP change that should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants