Skip to content

Commit d71e600

Browse files
authored
Fixed metric sampling hang condition (#616)
1 parent 15d3f93 commit d71e600

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/unitrace/src/levelzero/ze_metrics.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ class ZeMetricProfiler {
854854

855855
uint64_t cur_sampling_ts = 0;
856856
auto kit = kinfo.begin();
857-
while (!inf.eof()) {
857+
while (!inf.eof() && kit != kinfo.end()) {
858858
// Read metric data in two stages, first actual size (in bytes), followed by actual metrics
859859
uint64_t data_size;
860860
inf.read(reinterpret_cast<char *>(&data_size), sizeof(data_size));
@@ -1177,6 +1177,8 @@ class ZeMetricProfiler {
11771177
std::cerr << "[ERROR] Failed to write to sampling metrics file " << desc->metric_file_name_ << std::endl;
11781178
break;
11791179
}
1180+
if (size < MAX_METRIC_BUFFER)
1181+
break;
11801182
size = ReadMetrics(streamer, raw_metrics, MAX_METRIC_BUFFER);
11811183
}
11821184
free (raw_metrics);

0 commit comments

Comments
 (0)