Skip to content

Commit

Permalink
Fix profiling via sigusr2 (pytorch#412)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#412

Triggering profiling via sigusr2 caused a couple of configuration errors.
Also disable sigusr2 setup by default.

Reviewed By: chaekit, lw

Differential Revision: D30574351

fbshipit-source-id: 7857627c71eb16a3bc9c06ca35653a64baa63f5e
  • Loading branch information
gdankel authored and facebook-github-bot committed Sep 11, 2021
1 parent 6089dca commit 65cf64e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions libkineto/src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ Config::Config()
multiplexPeriod_(kDefaultMultiplexPeriodMsecs),
activityProfilerEnabled_(true),
activitiesLogFile_(defaultTraceFileName()),
activitiesLogUrl_(fmt::format("file://{}", activitiesLogFile_)),
activitiesMaxGpuBufferSize_(kDefaultActivitiesMaxGpuBufferSize),
activitiesWarmupDuration_(kDefaultActivitiesWarmupDurationSecs),
activitiesOnDemandDuration_(kDefaultActivitiesProfileDurationMSecs),
Expand All @@ -187,7 +188,7 @@ Config::Config()
activitiesOnDemandTimestamp_(milliseconds(0)),
profileStartTime_(milliseconds(0)),
requestTimestamp_(milliseconds(0)),
enableSigUsr2_(true),
enableSigUsr2_(false),
enableIpcFabric_(false) {
auto factories = configFactories();
if (factories) {
Expand Down Expand Up @@ -342,7 +343,8 @@ void Config::setClientDefaults() {
activitiesLogToMemory_ = true;
}

void Config::validate(const std::chrono::time_point<std::chrono::system_clock>& fallbackProfileStartTime) {
void Config::validate(
const time_point<system_clock>& fallbackProfileStartTime) {
if (samplePeriod_.count() == 0) {
LOG(WARNING) << "Sample period must be greater than 0, setting to 1ms";
samplePeriod_ = milliseconds(1);
Expand Down
3 changes: 2 additions & 1 deletion libkineto/src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ class Config : public AbstractConfig {

void printActivityProfilerConfig(std::ostream& s) const override;

void validate(const std::chrono::time_point<std::chrono::system_clock>& fallbackProfileStartTime) override;
void validate(
const std::chrono::time_point<std::chrono::system_clock>& fallbackProfileStartTime) override;

static void addConfigFactory(
std::string name,
Expand Down
6 changes: 4 additions & 2 deletions libkineto/src/ConfigLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <stdlib.h>
#include <chrono>
#include <fmt/format.h>
#include <fstream>

#include "DaemonConfigLoader.h"
Expand Down Expand Up @@ -224,8 +225,9 @@ void ConfigLoader::configureFromSignal(
Config& config) {
LOG(INFO) << "Received on-demand profiling signal, "
<< "reading config from " << kOnDemandConfigFile;
const std::string config_str =
readConfigFromConfigFile(kOnDemandConfigFile);
// Reset start time to 0 in order to compute new default start time
const std::string config_str = "PROFILE_START_TIME=0\n"
+ readConfigFromConfigFile(kOnDemandConfigFile);
config.parse(config_str);
config.setSignalDefaults();
notifyHandlers(config);
Expand Down

0 comments on commit 65cf64e

Please sign in to comment.