已合并
【Profiling】【同步9.0.0】修复订阅场景keypoint结构问题 #1335
komorebi创建于 3月31日
【Profiling】【同步9.0.0】修复订阅场景keypoint结构问题 #1335
已合并
komorebi创建于 3月31日
4 个文件变更+36-15
Msrc/dfx/msprof/collector/dvvp/analyze/inc/analyzer_ts.h+2-1
@@ -36,7 +36,8 @@ public:
36private:36private:
37 void ParseTsTrackData(CONST_CHAR_PTR data, uint32_t len);37 void ParseTsTrackData(CONST_CHAR_PTR data, uint32_t len);
38 void ParseTsTimelineData(CONST_CHAR_PTR data, uint32_t len);38 void ParseTsTimelineData(CONST_CHAR_PTR data, uint32_t len);
39- void ParseTsKeypointData(CONST_CHAR_PTR data, uint32_t len);39+ template<typename T>
40+ void ParseTsKeypointData(const T *tsData);
40 uint8_t GetRptType(CONST_CHAR_PTR data, uint32_t len);41 uint8_t GetRptType(CONST_CHAR_PTR data, uint32_t len);
41 42 
42 void PrintStats();43 void PrintStats();
Msrc/dfx/msprof/collector/dvvp/analyze/inc/data_struct.h+10-0
@@ -110,6 +110,16 @@ struct TsProfileKeypoint {
110 uint16_t resv;110 uint16_t resv;
111};111};
112 112 
113+struct TsDavidKeypoint {
114+ TsProfileDataHead head;
115+ uint64_t timestamp;
116+ uint64_t indexId;
117+ uint64_t modelId;
118+ uint16_t tagId;
119+ uint16_t streamId;
120+ uint32_t taskId;
121+};
122+ 
113// hwts123// hwts
114constexpr uint8_t HWTS_TASK_START_TYPE = 0;124constexpr uint8_t HWTS_TASK_START_TYPE = 0;
115constexpr uint8_t HWTS_TASK_END_TYPE = 1;125constexpr uint8_t HWTS_TASK_END_TYPE = 1;
Msrc/dfx/msprof/collector/dvvp/analyze/src/analyzer_ffts.cpp+3-1
@@ -100,7 +100,9 @@ void AnalyzerFfts::HandleOptimizeAcsqTaskData(const T *acsqLog, uint32_t logType
100 uint16_t streamId = acsqLog->streamId;100 uint16_t streamId = acsqLog->streamId;
101 std::string key;101 std::string key;
102 if (IsExtPmu()) {102 if (IsExtPmu()) {
103- key = std::to_string(taskId);103+ constexpr uint32_t offsetTask = 16;
104+ uint32_t extTaskId = (static_cast<uint32_t>(taskId) << offsetTask | streamId);
105+ key = std::to_string(extTaskId);
104 } else {106 } else {
105 StarsRollBackStreamTaskId(&streamId, &taskId);107 StarsRollBackStreamTaskId(&streamId, &taskId);
106 key = std::to_string(taskId) + KEY_SEPARATOR + std::to_string(streamId);108 key = std::to_string(taskId) + KEY_SEPARATOR + std::to_string(streamId);
Msrc/dfx/msprof/collector/dvvp/analyze/src/analyzer_ts.cpp+21-13
@@ -13,7 +13,7 @@
13namespace Analysis {13namespace Analysis {
14namespace Dvvp {14namespace Dvvp {
15namespace Analyze {15namespace Analyze {
16- 16+using namespace analysis::dvvp::common::utils;
17bool AnalyzerTs::IsTsData(const std::string &fileName)17bool AnalyzerTs::IsTsData(const std::string &fileName)
18{18{
19 // ts data contains "ts_track.data"19 // ts data contains "ts_track.data"
@@ -52,7 +52,8 @@ void AnalyzerTs::ParseTsTrackData(CONST_CHAR_PTR data, uint32_t len)
52 BufferRemainingData(dataLen_);52 BufferRemainingData(dataLen_);
53 return;53 return;
54 }54 }
55- if (remainingLen < tsHeader->bufSize) {55+ // sizeof(TsProfileKeypoint) equal to sizeof(TsDavidKeypoint)
56+ if (remainingLen < tsHeader->bufSize || remainingLen < sizeof(TsProfileKeypoint)) {
56 // remaining is not enough for bufSize to parse, cache it to buffer57 // remaining is not enough for bufSize to parse, cache it to buffer
57 MSPROF_LOGI("Ts remains %u bytes unparsed, bufSize %u, cache it", remainingLen, tsHeader->bufSize);58 MSPROF_LOGI("Ts remains %u bytes unparsed, bufSize %u, cache it", remainingLen, tsHeader->bufSize);
58 break;59 break;
@@ -61,7 +62,15 @@ void AnalyzerTs::ParseTsTrackData(CONST_CHAR_PTR data, uint32_t len)
61 // data check ok, parse it62 // data check ok, parse it
62 ParseTsTimelineData(dataPtr_ + offset, remainingLen);63 ParseTsTimelineData(dataPtr_ + offset, remainingLen);
63 } else if (tsHeader->rptType == TS_KEYPOINT_RPT_TYPE) {64 } else if (tsHeader->rptType == TS_KEYPOINT_RPT_TYPE) {
64- ParseTsKeypointData(dataPtr_ + offset, remainingLen);65+ if (IsExtPmu()) {
66+ const TsDavidKeypoint *tsData =
67+ Utils::ReinterpretCast<const TsDavidKeypoint, const TsProfileDataHead>(tsHeader);
68+ ParseTsKeypointData(tsData);
69+ } else {
70+ const TsProfileKeypoint *tsData =
71+ Utils::ReinterpretCast<const TsProfileKeypoint, const TsProfileDataHead>(tsHeader);
72+ ParseTsKeypointData(tsData);
73+ }
65 }74 }
66 offset += tsHeader->bufSize;75 offset += tsHeader->bufSize;
67 }76 }
@@ -120,17 +129,13 @@ void AnalyzerTs::ParseTsTimelineData(CONST_CHAR_PTR data, uint32_t len)
120 }129 }
121}130}
122 131 
123-void AnalyzerTs::ParseTsKeypointData(CONST_CHAR_PTR data, uint32_t len)132+template<typename T>
133+void AnalyzerTs::ParseTsKeypointData(const T *tsData)
124{134{
125- if (len < sizeof(TsProfileKeypoint)) {135+ if (tsData->head.bufSize != sizeof(T) || tsData->timestamp == 0) {
126- return;
127- }
128- 
129- auto tsData = reinterpret_cast<const TsProfileKeypoint *>(data);
130- if (tsData->head.bufSize != sizeof(TsProfileKeypoint) || tsData->timestamp == 0) {
131 MSPROF_LOGE("keypoint op error. bufSize %" PRIu64 " bytes, struct_len %u, "136 MSPROF_LOGE("keypoint op error. bufSize %" PRIu64 " bytes, struct_len %u, "
132 "indexId %" PRIu64 ", taskId %u, streamId %u, timestamp %" PRIu64, tsData->head.bufSize,137 "indexId %" PRIu64 ", taskId %u, streamId %u, timestamp %" PRIu64, tsData->head.bufSize,
133- sizeof(TsProfileKeypoint), tsData->indexId, tsData->taskId, tsData->streamId, tsData->timestamp);138+ sizeof(T), tsData->indexId, tsData->taskId, tsData->streamId, tsData->timestamp);
134 return;139 return;
135 }140 }
136 141 
@@ -149,7 +154,7 @@ void AnalyzerTs::ParseTsKeypointData(CONST_CHAR_PTR data, uint32_t len)
149 opData.indexId = tsData->indexId;154 opData.indexId = tsData->indexId;
150 opData.modelId = tsData->modelId;155 opData.modelId = tsData->modelId;
151 opData.streamId = tsData->streamId;156 opData.streamId = tsData->streamId;
152- opData.taskId = tsData->taskId;157+ opData.taskId = static_cast<uint16_t>(tsData->taskId);
153 opData.uploaded = false;158 opData.uploaded = false;
154 keypointOpInfo_[key] = opData;159 keypointOpInfo_[key] = opData;
155 } else if (tsData->tagId == TS_KEYPOINT_END_TASK_STATE) {160 } else if (tsData->tagId == TS_KEYPOINT_END_TASK_STATE) {
@@ -176,7 +181,7 @@ void AnalyzerTs::ParseTsKeypointData(CONST_CHAR_PTR data, uint32_t len)
176 MSPROF_LOGE("keypoint tagId error. tagId %u", tsData->tagId);181 MSPROF_LOGE("keypoint tagId error. tagId %u", tsData->tagId);
177 return;182 return;
178 }183 }
179- analyzedBytes_ += sizeof(TsProfileKeypoint);184+ analyzedBytes_ += sizeof(T);
180}185}
181 186 
182void AnalyzerTs::PrintStats()187void AnalyzerTs::PrintStats()
@@ -196,6 +201,9 @@ void AnalyzerTs::PrintStats()
196 times,201 times,
197 totalTsMerges_);202 totalTsMerges_);
198}203}
204+ 
205+template void AnalyzerTs::ParseTsKeypointData(const TsProfileKeypoint *tsData);
206+template void AnalyzerTs::ParseTsKeypointData(const TsDavidKeypoint *tsData);
199} // namespace Analyze207} // namespace Analyze
200} // namespace Dvvp208} // namespace Dvvp
201} // namespace Analysis209} // namespace Analysis