Skip to content

Commit 0f17096

Browse files
sraikund16facebook-github-bot
authored andcommitted
Don't Allow Profiling Thread to pick up wrong config (#1076)
Summary: Now that we have two types of on-demand threads accepting requests (GPU Traces + Memory Snapshots) we need to lock out one thread from using another's request. Right now there is a possibility that a user does memory profiling then gpu trace profiling which will cause the second trace to be invalid. NOTE: To get both types of requests working in a single run, we will need a follow up diff in which both threads can be instantiated and tracked. Currently, if we make one type of thread, we lock out the other. This diff is an incremental step towards getting both to work. Differential Revision: D72980123
1 parent 856c48c commit 0f17096

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

libkineto/src/ActivityProfilerController.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ bool ActivityProfilerController::shouldActivateTimestampConfig(
146146
if (asyncRequestConfig_->hasProfileStartIteration()) {
147147
return false;
148148
}
149+
if (asyncRequestConfig_->memoryProfilerEnabled()) {
150+
return false;
151+
}
149152
// Note on now + Config::kControllerIntervalMsecs:
150153
// Profiler interval does not align perfectly up to startTime - warmup.
151154
// Waiting until the next tick won't allow sufficient time for the profiler to
@@ -168,6 +171,9 @@ bool ActivityProfilerController::shouldActivateIterationConfig(
168171
if (!asyncRequestConfig_->hasProfileStartIteration()) {
169172
return false;
170173
}
174+
if (asyncRequestConfig_->memoryProfilerEnabled()) {
175+
return false;
176+
}
171177
auto rootIter = asyncRequestConfig_->startIterationIncludingWarmup();
172178
// Keep waiting, it is not time to start yet.
173179
if (currentIter < rootIter) {
@@ -252,7 +258,8 @@ void ActivityProfilerController::memoryProfilerLoop() {
252258
// Perform Double-checked locking to reduce overhead of taking lock.
253259
if (asyncRequestConfig_ && !profiler_->isActive()) {
254260
std::lock_guard<std::mutex> lock(asyncConfigLock_);
255-
if (asyncRequestConfig_ && !profiler_->isActive()) {
261+
if (asyncRequestConfig_ && !profiler_->isActive() &&
262+
asyncRequestConfig_->memoryProfilerEnabled()) {
256263
logger_ = makeLogger(*asyncRequestConfig_);
257264
path = asyncRequestConfig_->activitiesLogFile();
258265
profile_time = asyncRequestConfig_->profileMemoryDuration();

0 commit comments

Comments
 (0)