From 6d53c1b67b354e972b5629ee18c4d598dd314586 Mon Sep 17 00:00:00 2001 From: jichuan Date: Tue, 9 Jul 2024 10:21:20 +0800 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E6=94=AF=E6=8C=81raw=20trace=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=88=87=E5=89=B2=E4=BF=AE=E6=94=B9StartTs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- ide/src/trace/component/SpFlags.ts | 5 +++++ trace_streamer/src/rpc/rpc_server.cpp | 5 +++++ trace_streamer/src/trace_data/trace_data_cache.cpp | 9 ++++++++- trace_streamer/src/trace_data/trace_data_cache.h | 3 +++ .../src/trace_streamer/trace_streamer_selector.cpp | 4 ++++ .../src/trace_streamer/trace_streamer_selector.h | 1 + 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ide/src/trace/component/SpFlags.ts b/ide/src/trace/component/SpFlags.ts index d50ac6e7..280d2a7a 100644 --- a/ide/src/trace/component/SpFlags.ts +++ b/ide/src/trace/component/SpFlags.ts @@ -254,6 +254,11 @@ export class FlagsConfig { switchOptions: [{ option: 'Enabled' }, { option: 'Disabled', selected: true }], describeContent: 'The real CPU after being split by irq and softirq', }, + { + title: 'RawTraceCutStartTs', + switchOptions: [{ option: 'Enabled' }, { option: 'Disabled', selected: true }], + describeContent: 'Raw Trace Cut By StartTs, StartTs = Max(Cpu1 StartTs, Cpu2 StartTs, ..., CpuN StartTs)', + }, ]; static getAllFlagConfig(): Array { diff --git a/trace_streamer/src/rpc/rpc_server.cpp b/trace_streamer/src/rpc/rpc_server.cpp index 34aa13d7..82f5bbe3 100644 --- a/trace_streamer/src/rpc/rpc_server.cpp +++ b/trace_streamer/src/rpc/rpc_server.cpp @@ -54,6 +54,7 @@ struct ParserConfig { int32_t binderConfigValue; int32_t ffrtConvertConfigValue; int32_t HMKernelConfigValue; + int32_t rawTraceCutStartTsValue; }; void from_json(const json &j, ParserConfig &v) { @@ -63,6 +64,9 @@ void from_json(const json &j, ParserConfig &v) j.at("BinderRunnable").get_to(v.binderConfigValue); j.at("FfrtConvert").get_to(v.ffrtConvertConfigValue); j.at("HMKernel").get_to(v.HMKernelConfigValue); + if (j.contains("RawTraceCutStartTs")) { + v.rawTraceCutStartTsValue = j.at("RawTraceCutStartTs"); + } } } // namespace jsonns #if IS_WASM @@ -768,6 +772,7 @@ bool RpcServer::ParserConfig(std::string parserConfigJson) ts_->UpdateTaskPoolTraceStatus(parserConfig.taskConfigValue); ts_->UpdateBinderRunnableTraceStatus(parserConfig.binderConfigValue); ts_->UpdateHMKernelTraceStatus(parserConfig.HMKernelConfigValue); + ts_->UpdateRawTraceCutStartTsStatus(parserConfig.rawTraceCutStartTsValue); ffrtConvertEnabled_ = parserConfig.ffrtConvertConfigValue; startParseTime_ = (std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch())) diff --git a/trace_streamer/src/trace_data/trace_data_cache.cpp b/trace_streamer/src/trace_data/trace_data_cache.cpp index 78b8a3b5..ee159f36 100644 --- a/trace_streamer/src/trace_data/trace_data_cache.cpp +++ b/trace_streamer/src/trace_data/trace_data_cache.cpp @@ -287,11 +287,18 @@ bool TraceDataCache::HMKernelTraceEnabled() const { return HMKernelTraceEnabled_; } - void TraceDataCache::UpdateHMKernelTraceStatus(bool status) { HMKernelTraceEnabled_ = status; } +bool TraceDataCache::RawTraceCutStartTsEnabled() const +{ + return rawTraceCutStartTsEnabled_; +} +void TraceDataCache::UpdateRawTraceCutStartTsStatus(bool status) +{ + rawTraceCutStartTsEnabled_ = status; +} uint64_t TraceDataCache::SplitFileMaxTime() { return splitFileMaxTs_; diff --git a/trace_streamer/src/trace_data/trace_data_cache.h b/trace_streamer/src/trace_data/trace_data_cache.h index 0d2d7ee6..4cf27f95 100644 --- a/trace_streamer/src/trace_data/trace_data_cache.h +++ b/trace_streamer/src/trace_data/trace_data_cache.h @@ -41,6 +41,8 @@ public: void UpdateBinderRunnableTraceStatus(bool status); bool HMKernelTraceEnabled() const; void UpdateHMKernelTraceStatus(bool status); + bool RawTraceCutStartTsEnabled() const; + void UpdateRawTraceCutStartTsStatus(bool status); uint64_t SplitFileMaxTime(); uint64_t SplitFileMinTime(); void SetSplitFileMaxTime(uint64_t maxTs); @@ -88,6 +90,7 @@ private: bool appStartTraceEnabled_ = false; bool binderRunnableTraceEnabled_ = false; bool HMKernelTraceEnabled_ = false; + bool rawTraceCutStartTsEnabled_ = false; uint64_t splitFileMinTs_ = INVALID_UINT64; uint64_t splitFileMaxTs_ = INVALID_UINT64; std::deque> hookCommProtos_; diff --git a/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp b/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp index 6d8aab3f..d747e968 100644 --- a/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp +++ b/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp @@ -518,6 +518,10 @@ void TraceStreamerSelector::UpdateHMKernelTraceStatus(bool status) { traceDataCache_->UpdateHMKernelTraceStatus(status); } +void TraceStreamerSelector::UpdateRawTraceCutStartTsStatus(bool status) +{ + traceDataCache_->UpdateRawTraceCutStartTsStatus(status); +} bool TraceStreamerSelector::LoadQueryFile(const std::string &sqlOperator, std::vector &sqlStrings) { std::ifstream file(sqlOperator); diff --git a/trace_streamer/src/trace_streamer/trace_streamer_selector.h b/trace_streamer/src/trace_streamer/trace_streamer_selector.h index c34ba724..e0097457 100644 --- a/trace_streamer/src/trace_streamer/trace_streamer_selector.h +++ b/trace_streamer/src/trace_streamer/trace_streamer_selector.h @@ -65,6 +65,7 @@ public: void UpdateAppStartTraceStatus(bool status); void UpdateBinderRunnableTraceStatus(bool status); void UpdateHMKernelTraceStatus(bool status); + void UpdateRawTraceCutStartTsStatus(bool status); void InitMetricsMap(std::map &metricsMap); const std::string MetricsSqlQuery(const std::string &metrics); auto GetPtreaderParser() -- Gitee From e6b8773fcd46442db132602f53de4a9caf2836fc Mon Sep 17 00:00:00 2001 From: jichuan Date: Tue, 9 Jul 2024 11:40:31 +0800 Subject: [PATCH 2/7] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9RawTraceCutStartTs?= =?UTF-8?q?=E5=BC=80=E5=85=B3=E9=BB=98=E8=AE=A4=E7=8A=B6=E6=80=81=E4=B8=BA?= =?UTF-8?q?true?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- ide/src/trace/component/SpFlags.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ide/src/trace/component/SpFlags.ts b/ide/src/trace/component/SpFlags.ts index 280d2a7a..2b4c86d0 100644 --- a/ide/src/trace/component/SpFlags.ts +++ b/ide/src/trace/component/SpFlags.ts @@ -256,7 +256,7 @@ export class FlagsConfig { }, { title: 'RawTraceCutStartTs', - switchOptions: [{ option: 'Enabled' }, { option: 'Disabled', selected: true }], + switchOptions: [{ option: 'Enabled', selected: true }, { option: 'Disabled' }], describeContent: 'Raw Trace Cut By StartTs, StartTs = Max(Cpu1 StartTs, Cpu2 StartTs, ..., CpuN StartTs)', }, ]; -- Gitee From 10e784ef26a3bf858e88730ac7a124410c24410b Mon Sep 17 00:00:00 2001 From: jichuan Date: Tue, 9 Jul 2024 11:42:58 +0800 Subject: [PATCH 3/7] =?UTF-8?q?fix:=20=E9=80=82=E9=85=8DH:ReceiveVsync?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E6=A0=BC=E5=BC=8F=E5=8F=98=E5=8C=96,=20?= =?UTF-8?q?=E6=AD=A3=E5=88=99=E8=BF=87=E6=BB=A4:=E5=90=8E=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=9A=84=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- trace_streamer/src/parser/print_event_parser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trace_streamer/src/parser/print_event_parser.h b/trace_streamer/src/parser/print_event_parser.h index 6b26d035..c97da532 100644 --- a/trace_streamer/src/parser/print_event_parser.h +++ b/trace_streamer/src/parser/print_event_parser.h @@ -92,7 +92,7 @@ private: const std::string onAnimationProcEvent_ = "render_service"; const DataIndex marshRwTransactionData_ = traceDataCache_->GetDataIndex("H:MarshRSTransactionData"); const DataIndex rsMainThreadProcessCmd_ = traceDataCache_->GetDataIndex("H:RSMainThread::ProcessCommandUni"); - const std::regex recvVsyncPattern_ = std::regex("(\\w+):(\\w+)"); + const std::regex recvVsyncPattern_ = std::regex(R"((\w+):\s*(\w+))"); const std::regex transFlagPattern_ = std::regex("transactionFlag:\\[(\\d+),(\\d+)\\]"); const std::regex mainProcessCmdPattern_ = std::regex("\\[(\\d+),(\\d+)\\]"); const std::regex distributeMatcher_ = std::regex(R"(H:\[([a-z0-9]+),([a-z0-9]+),([a-z0-9]+)\]#([CS]?)##(.*))"); -- Gitee From 44430f11672396e5e40eb5116bf4dfdd8a7fa60e Mon Sep 17 00:00:00 2001 From: jichuan Date: Tue, 9 Jul 2024 11:51:11 +0800 Subject: [PATCH 4/7] =?UTF-8?q?fix:=20sleep=E7=8A=B6=E6=80=81=E7=9A=84bloc?= =?UTF-8?q?ked=5Freason=E4=B8=8D=E5=81=9A=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- trace_streamer/src/filter/cpu_filter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/trace_streamer/src/filter/cpu_filter.cpp b/trace_streamer/src/filter/cpu_filter.cpp index 3a061190..a280fcb8 100644 --- a/trace_streamer/src/filter/cpu_filter.cpp +++ b/trace_streamer/src/filter/cpu_filter.cpp @@ -94,6 +94,10 @@ void CpuFilter::ProcPrevPidSwitchEvent(uint64_t ts, } else { pidToThreadSliceRow_.at(prevPid) = threadStateRow; } + } else { + if (pidToThreadSliceRow_.count(prevPid)) { + pidToThreadSliceRow_.erase(prevPid); + } } (void)RemberInternalTidInStateTable(prevPid, threadStateRow, prevState); } -- Gitee From 5190609130c5fadb9c094b0ca993c4d20171ea8a Mon Sep 17 00:00:00 2001 From: jichuan Date: Tue, 9 Jul 2024 11:52:59 +0800 Subject: [PATCH 5/7] =?UTF-8?q?fix:=20mem=E6=8F=92=E4=BB=B6windowNameId?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- .../parser/pbreader_parser/mem_parser/pbreader_mem_parser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.cpp b/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.cpp index 0457bedf..0f4ad040 100644 --- a/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.cpp @@ -592,6 +592,7 @@ void PbreaderMemParser::FillGpuWindowMemInfo(const ProtoReader::GpuDumpInfo_Read { DataIndex windowNameId = traceDataCache_->GetDataIndex(gpuDumpInfo.window_name().ToStdString()); GpuWindowMemRow row; + row.windowNameId = windowNameId; row.ts = timeStamp; row.windowId = gpuDumpInfo.id(); row.purgeableSize = gpuDumpInfo.gpu_purgeable_size(); -- Gitee From 9366c7fcc9690b95f04644b008359cf1625155ba Mon Sep 17 00:00:00 2001 From: jichuan Date: Tue, 9 Jul 2024 11:56:01 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20TracingMarkWrite=E4=BA=8B=E4=BB=B6ra?= =?UTF-8?q?w=20trace=E8=A7=A3=E6=9E=90format=20size=E4=B8=B4=E7=95=8C?= =?UTF-8?q?=E5=80=BC=E4=BB=8E60=E6=9B=B4=E6=94=B9=E4=B8=BA20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- .../src/parser/rawtrace_parser/ftrace_event_processor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp b/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp index 58e0c9c5..a7ef062e 100644 --- a/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp @@ -434,8 +434,8 @@ bool FtraceEventProcessor::TracingMarkWriteOrPrintFormat(FtraceEvent &ftraceEven if (format.eventId < HM_EVENT_ID_OFFSET) { printMsg->set_ip(FtraceFieldProcessor::HandleIntField(format.fields, index++, data, size)); } - // size大于60时为适配内核的event,小于则为原始的event - if (format.eventSize > 60) { + // size大于20时为适配内核的event,小于则为原始的event + if (format.eventSize > 20) { auto pid = FtraceFieldProcessor::HandleIntField(format.fields, index++, data, size); auto name = FtraceFieldProcessor::HandleStrField(format.fields, index++, data, size); auto start = FtraceFieldProcessor::HandleIntField(format.fields, index++, data, size); -- Gitee From 799ebe43dda9e5f3b83490e964ce10ea03e31cb5 Mon Sep 17 00:00:00 2001 From: jichuan Date: Tue, 9 Jul 2024 14:21:47 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9RawTraceCutStartTs?= =?UTF-8?q?=E5=BC=80=E5=85=B3=E9=BB=98=E8=AE=A4=E7=8A=B6=E6=80=81=E4=B8=BA?= =?UTF-8?q?true?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jichuan --- trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp | 3 +++ trace_streamer/src/trace_data/trace_data_cache.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp b/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp index 32d8b31f..0459ccdb 100644 --- a/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp @@ -46,6 +46,9 @@ void RawTraceParser::WaitForParserEnd() } void RawTraceParser::UpdateTraceMinRange() { + if (!traceDataCache_->RawTraceCutStartTsEnabled()) { + return; + } auto schedSlice = traceDataCache_->GetConstSchedSliceData(); std::set uniqueCpuIdSet; uint64_t cpuRunningStatMinTime = INVALID_TIME; diff --git a/trace_streamer/src/trace_data/trace_data_cache.h b/trace_streamer/src/trace_data/trace_data_cache.h index 4cf27f95..7cbdcf91 100644 --- a/trace_streamer/src/trace_data/trace_data_cache.h +++ b/trace_streamer/src/trace_data/trace_data_cache.h @@ -90,7 +90,7 @@ private: bool appStartTraceEnabled_ = false; bool binderRunnableTraceEnabled_ = false; bool HMKernelTraceEnabled_ = false; - bool rawTraceCutStartTsEnabled_ = false; + bool rawTraceCutStartTsEnabled_ = true; uint64_t splitFileMinTs_ = INVALID_UINT64; uint64_t splitFileMaxTs_ = INVALID_UINT64; std::deque> hookCommProtos_; -- Gitee