diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-06-05 04:31:37 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-06-05 04:31:37 +0000 |
commit | 39fdcba9767aad7b02843f7c8f4067d4668d753e (patch) | |
tree | 80b427899d014e5255becc68ece1bc75e131cba3 | |
parent | c1d4f98938b76ccd2b0f4a1d854a28a5635bb4db (diff) | |
parent | 61207fb695bf65b47c09ac8d06e7e599ce761059 (diff) | |
download | perfetto-39fdcba9767aad7b02843f7c8f4067d4668d753e.tar.gz |
Snap for 5617038 from 61207fb695bf65b47c09ac8d06e7e599ce761059 to qt-aml-release
Change-Id: I13383b81633a2cca4e2a8e0a4ca38b7db5d55fac
-rw-r--r-- | protos/perfetto/trace/perfetto_trace.proto | 19 | ||||
-rw-r--r-- | protos/perfetto/trace/ps/process_stats.proto | 9 | ||||
-rw-r--r-- | protos/perfetto/trace/ps/process_tree.proto | 5 | ||||
-rw-r--r-- | protos/perfetto/trace/sys_stats/sys_stats.proto | 5 | ||||
-rw-r--r-- | src/traced/probes/ps/process_stats_data_source.cc | 29 | ||||
-rw-r--r-- | src/traced/probes/ps/process_stats_data_source.h | 15 | ||||
-rw-r--r-- | src/traced/probes/sys_stats/sys_stats_data_source.cc | 3 |
7 files changed, 4 insertions, 81 deletions
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto index 52676a241..d57288446 100644 --- a/protos/perfetto/trace/perfetto_trace.proto +++ b/protos/perfetto/trace/perfetto_trace.proto @@ -2706,15 +2706,6 @@ message ProcessStats { optional int64 oom_score_adj = 10; } repeated Process processes = 1; - - // The time at which we finish collecting this batch of samples; - // the top-level packet timestamp is the time at which - // we begin collection. - // TODO(dancol): analysis might be improved by - // time-bracketing each sample as well as the whole - // ProcessStats, but doing that is probably gated on - // a vdso for CLOCK_BOOTTIME. - optional uint64 collection_end_timestamp = 2; } // End of protos/perfetto/trace/ps/process_stats.proto @@ -2761,11 +2752,6 @@ message ProcessTree { // #2 { processes: [{pid: 20, ...}], threads: [{pid: 13, tgid: 10}] } repeated Process processes = 1; repeated Thread threads = 2; - - // The time at which we finish collecting this process tree; - // the top-level packet timestamp is the time at which - // we begin collection. - optional uint64 collection_end_timestamp = 3; } // End of protos/perfetto/trace/ps/process_tree.proto @@ -2821,11 +2807,6 @@ message SysStats { // Populated only if SOFTIRQ_COUNTS in config.stat_counters. optional uint64 num_softirq_total = 7; // Total num of softirqs since boot. repeated InterruptCount num_softirq = 8; // Per-softirq count. - - // The time at which we finish collecting this set of samples; - // the top-level packet timestamp is the time at which - // we begin collection. - optional uint64 collection_end_timestamp = 9; } // End of protos/perfetto/trace/sys_stats/sys_stats.proto diff --git a/protos/perfetto/trace/ps/process_stats.proto b/protos/perfetto/trace/ps/process_stats.proto index 5db028f81..49e8237c4 100644 --- a/protos/perfetto/trace/ps/process_stats.proto +++ b/protos/perfetto/trace/ps/process_stats.proto @@ -43,13 +43,4 @@ message ProcessStats { optional int64 oom_score_adj = 10; } repeated Process processes = 1; - - // The time at which we finish collecting this batch of samples; - // the top-level packet timestamp is the time at which - // we begin collection. - // TODO(dancol): analysis might be improved by - // time-bracketing each sample as well as the whole - // ProcessStats, but doing that is probably gated on - // a vdso for CLOCK_BOOTTIME. - optional uint64 collection_end_timestamp = 2; } diff --git a/protos/perfetto/trace/ps/process_tree.proto b/protos/perfetto/trace/ps/process_tree.proto index cf83d12b3..50579e52d 100644 --- a/protos/perfetto/trace/ps/process_tree.proto +++ b/protos/perfetto/trace/ps/process_tree.proto @@ -58,9 +58,4 @@ message ProcessTree { // #2 { processes: [{pid: 20, ...}], threads: [{pid: 13, tgid: 10}] } repeated Process processes = 1; repeated Thread threads = 2; - - // The time at which we finish collecting this process tree; - // the top-level packet timestamp is the time at which - // we begin collection. - optional uint64 collection_end_timestamp = 3; } diff --git a/protos/perfetto/trace/sys_stats/sys_stats.proto b/protos/perfetto/trace/sys_stats/sys_stats.proto index 4b10ecfca..7b298bf9c 100644 --- a/protos/perfetto/trace/sys_stats/sys_stats.proto +++ b/protos/perfetto/trace/sys_stats/sys_stats.proto @@ -69,9 +69,4 @@ message SysStats { // Populated only if SOFTIRQ_COUNTS in config.stat_counters. optional uint64 num_softirq_total = 7; // Total num of softirqs since boot. repeated InterruptCount num_softirq = 8; // Per-softirq count. - - // The time at which we finish collecting this set of samples; - // the top-level packet timestamp is the time at which - // we begin collection. - optional uint64 collection_end_timestamp = 9; } diff --git a/src/traced/probes/ps/process_stats_data_source.cc b/src/traced/probes/ps/process_stats_data_source.cc index e994c2d7e..524a8b468 100644 --- a/src/traced/probes/ps/process_stats_data_source.cc +++ b/src/traced/probes/ps/process_stats_data_source.cc @@ -136,9 +136,6 @@ base::WeakPtr<ProcessStatsDataSource> ProcessStatsDataSource::GetWeakPtr() void ProcessStatsDataSource::WriteAllProcesses() { PERFETTO_METATRACE("WriteAllProcesses", 0); PERFETTO_DCHECK(!cur_ps_tree_); - - CacheProcFsScanStartTimestamp(); - base::ScopedDir proc_dir = OpenProcDir(); if (!proc_dir) return; @@ -202,9 +199,6 @@ void ProcessStatsDataSource::Flush(FlushRequestID, } void ProcessStatsDataSource::WriteProcessOrThread(int32_t pid) { - // In case we're called from outside WriteAllProcesses() - CacheProcFsScanStartTimestamp(); - std::string proc_status = ReadProcPidFile(pid, "status"); if (proc_status.empty()) return; @@ -286,7 +280,8 @@ void ProcessStatsDataSource::StartNewPacketIfNeeded() { if (cur_packet_) return; cur_packet_ = writer_->NewTracePacket(); - cur_packet_->set_timestamp(CacheProcFsScanStartTimestamp()); + uint64_t now = static_cast<uint64_t>(base::GetBootTimeNs().count()); + cur_packet_->set_timestamp(now); if (did_clear_incremental_state_) { cur_packet_->set_incremental_state_cleared(true); @@ -324,17 +319,9 @@ ProcessStatsDataSource::GetOrCreateStatsProcess(int32_t pid) { void ProcessStatsDataSource::FinalizeCurPacket() { PERFETTO_DCHECK(!cur_ps_tree_ || cur_packet_); PERFETTO_DCHECK(!cur_ps_stats_ || cur_packet_); - uint64_t now = static_cast<uint64_t>(base::GetBootTimeNs().count()); - if (cur_ps_tree_) { - cur_ps_tree_->set_collection_end_timestamp(now); - cur_ps_tree_ = nullptr; - } - if (cur_ps_stats_) { - cur_ps_stats_->set_collection_end_timestamp(now); - cur_ps_stats_ = nullptr; - } + cur_ps_tree_ = nullptr; + cur_ps_stats_ = nullptr; cur_ps_stats_process_ = nullptr; - cur_procfs_scan_start_timestamp_ = 0; cur_packet_ = TraceWriter::TracePacketHandle{}; } @@ -362,7 +349,6 @@ void ProcessStatsDataSource::WriteAllProcessStats() { // TODO(primiano): Have a pid cache to avoid wasting cycles reading kthreads // proc files over and over. Same for non-whitelist processes (see above). - CacheProcFsScanStartTimestamp(); PERFETTO_METATRACE("WriteAllProcessStats", 0); base::ScopedDir proc_dir = OpenProcDir(); if (!proc_dir) @@ -519,13 +505,6 @@ bool ProcessStatsDataSource::WriteMemCounters(int32_t pid, return proc_status_has_mem_counters; } -uint64_t ProcessStatsDataSource::CacheProcFsScanStartTimestamp() { - if (!cur_procfs_scan_start_timestamp_) - cur_procfs_scan_start_timestamp_ = - static_cast<uint64_t>(base::GetBootTimeNs().count()); - return cur_procfs_scan_start_timestamp_; -} - void ProcessStatsDataSource::ClearIncrementalState() { PERFETTO_DLOG("ProcessStatsDataSource clearing incremental state."); seen_pids_.clear(); diff --git a/src/traced/probes/ps/process_stats_data_source.h b/src/traced/probes/ps/process_stats_data_source.h index c0288f1f3..efea49487 100644 --- a/src/traced/probes/ps/process_stats_data_source.h +++ b/src/traced/probes/ps/process_stats_data_source.h @@ -104,26 +104,11 @@ class ProcessStatsDataSource : public ProbesDataSource { void WriteAllProcessStats(); bool WriteMemCounters(int32_t pid, const std::string& proc_status); - // Read and "latch" the current procfs scan-start timestamp, which - // we reset only in FinalizeCurPacket. - uint64_t CacheProcFsScanStartTimestamp(); - // Common fields used for both process/tree relationships and stats/counters. base::TaskRunner* const task_runner_; std::unique_ptr<TraceWriter> writer_; TraceWriter::TracePacketHandle cur_packet_; - // Cached before-scan timestamp; zero means cached time is absent. - // By the time we create the trace packet into which we dump procfs - // scan results, we've already read at least one bit of data from - // procfs, and by that point, it's too late to snap a timestamp from - // before we started looking at procfs at all, which is what trace - // analysis wants. To solve this problem, we record the scan-start - // timestamp here when we first open something in procfs and use - // that time when we create the packet. - // We reset this field after each FinalizeCurPacket(). - uint64_t cur_procfs_scan_start_timestamp_ = 0; - // Fields for keeping track of the state of process/tree relationships. protos::pbzero::ProcessTree* cur_ps_tree_ = nullptr; bool record_thread_names_ = false; diff --git a/src/traced/probes/sys_stats/sys_stats_data_source.cc b/src/traced/probes/sys_stats/sys_stats_data_source.cc index 217b196a7..befe3966c 100644 --- a/src/traced/probes/sys_stats/sys_stats_data_source.cc +++ b/src/traced/probes/sys_stats/sys_stats_data_source.cc @@ -174,9 +174,6 @@ void SysStatsDataSource::ReadSysStats() { if (stat_ticks_ && tick_ % stat_ticks_ == 0) ReadStat(sys_stats); - sys_stats->set_collection_end_timestamp( - static_cast<uint64_t>(base::GetBootTimeNs().count())); - tick_++; } |