Add cpu cycles stolen by host in perfetto traces (in case of emulator)
I am running some perf tests on emulator and see variable results on the same host. I have fixed frequencies of host, so that isn't a variable. But one other thing, that I see causing variability in wall clock time is when host steals cycles from guest. In other words, when vcpu is ready to run but was not allowed to run In the host. If I take trace and can capture cpu stats from /proc/stat with 'steal' cycles, would help clarify this situation. In /proc/stat 8th column is called 'steal' time.
Changes are pretty straight forward: a) in sys_stats.proto, we need to add one more field after softirq_ns: optional uint64 steal_ns = 9; b) same in perfetto_trace.proto c) in sys_stats_data_source.cc, add this after set_softirq_ns: cpu_stat->set_steal_ns(cpu_times[7] * ns_per_user_hz_); (and change vector cpu_times size to 8)
And then in tarce processor:
d) in system_probes_parser.cc:
push counter after softirq_ns:
context_->event_tracker->PushCounter(ts, static_cast
That is it and then these show up in perfetto UI, when run new binaries on device and tarce_processor_shell on host.
I can submit CL as well. Pls let me know.
Hi, This is indeed a very nice to have feature. Could you please send a Pull Request for us to review and merge? Thanks
https://github.com/google/perfetto/pull/1141
LGTM.
Cl has landed thanks for the contribution!