Skip to content

Commit

Permalink
Partially fix two bugs in HTContainer
Browse files Browse the repository at this point in the history
- when buffer is too small, it won't register;
- the buffer is not cleared
  • Loading branch information
vgene committed Jul 17, 2024
1 parent 6fb2e32 commit 51f1abe
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/runtime/ProfilingModules/HTContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,12 @@ class HTMap_Sum {
const auto set_size = buffer.size() / thread_count;
const auto buffer_size = buffer.size();

// FIXME: this is not correct when it's not filling up
auto begin = id * (buffer_size / thread_count);
auto end = (id + 1) * (buffer_size / thread_count);
if (id == thread_count - 1) {
end = buffer_size;
}

// for each element in the chunk, insert into the map, and increment the
// count from begin to end
Expand Down Expand Up @@ -517,6 +521,9 @@ class HTMap_Sum {
it->second++;
}
}

buffer.resize(0);
buffer.reserve(BUFFER_SIZE);
return;
}

Expand All @@ -541,6 +548,8 @@ class HTMap_Sum {
break;
}
}
buffer.resize(0);
buffer.reserve(BUFFER_SIZE);
#endif

#ifndef HT_THREAD_POOL
Expand Down Expand Up @@ -721,6 +730,8 @@ class HTMap_Min {
// provide [] operator
auto &operator[](const TK &key) {
convertVectorToSet(true);
buffer.resize(0);
buffer.reserve(BUFFER_SIZE);
return map[key];
}

Expand Down

0 comments on commit 51f1abe

Please sign in to comment.