Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewkotila committed Aug 8, 2023
1 parent 758cfa0 commit 2f7b455
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 111 deletions.
8 changes: 4 additions & 4 deletions src/c++/perf_analyzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ set(
infer_data_manager.cc
infer_data_manager_shm.cc
sequence_manager.cc
raw_data_collector.cc
raw_data_reporter.cc
profile_data_collector.cc
profile_data_exporter.cc
)

set(
Expand Down Expand Up @@ -107,8 +107,8 @@ set(
fifo_ctx_id_tracker.h
rand_ctx_id_tracker.h
request_record.h
raw_data_collector.h
raw_data_reporter.h
profile_data_collector.h
profile_data_exporter.h
)

add_executable(
Expand Down
2 changes: 2 additions & 0 deletions src/c++/perf_analyzer/client_backend/client_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -633,3 +633,5 @@ class InferResult {
};

}}} // namespace triton::perfanalyzer::clientbackend

namespace cb = triton::perfanalyzer::clientbackend;
6 changes: 3 additions & 3 deletions src/c++/perf_analyzer/inference_profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ InferenceProfiler::Create(
uint64_t measurement_request_count, MeasurementMode measurement_mode,
std::shared_ptr<MPIDriver> mpi_driver, const uint64_t metrics_interval_ms,
const bool should_collect_metrics, const double overhead_pct_threshold,
const std::shared_ptr<RawDataCollector> collector)
const std::shared_ptr<ProfileDataCollector> collector)
{
std::unique_ptr<InferenceProfiler> local_profiler(new InferenceProfiler(
verbose, stability_threshold, measurement_window_ms, max_trials,
Expand All @@ -495,7 +495,7 @@ InferenceProfiler::InferenceProfiler(
MeasurementMode measurement_mode, std::shared_ptr<MPIDriver> mpi_driver,
const uint64_t metrics_interval_ms, const bool should_collect_metrics,
const double overhead_pct_threshold,
const std::shared_ptr<RawDataCollector> collector)
const std::shared_ptr<ProfileDataCollector> collector)
: verbose_(verbose), measurement_window_ms_(measurement_window_ms),
max_trials_(max_trials), extra_percentile_(extra_percentile),
percentile_(percentile), latency_threshold_ms_(latency_threshold_ms_),
Expand Down Expand Up @@ -1316,7 +1316,7 @@ InferenceProfiler::CollectData(
PerfStatus& summary, uint64_t window_start_ns, uint64_t window_end_ns,
std::vector<RequestRecord>&& request_records)
{
PerfMode id{summary.concurrency, summary.request_rate};
InferenceLoadMode id{summary.concurrency, summary.request_rate};
collector_->AddWindow(id, window_start_ns, window_end_ns);
collector_->AddData(id, std::move(request_records));
}
Expand Down
13 changes: 6 additions & 7 deletions src/c++/perf_analyzer/inference_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "metrics_manager.h"
#include "model_parser.h"
#include "mpi_utils.h"
#include "raw_data_collector.h"
#include "profile_data_collector.h"
#include "request_rate_manager.h"

namespace triton { namespace perfanalyzer {
Expand Down Expand Up @@ -222,8 +222,7 @@ class InferenceProfiler {
/// should be collected.
/// \param overhead_pct_threshold User set threshold above which the PA
/// overhead is too significant to provide usable results.
/// \param collector Collects all of the raw data from experiments into a
/// central location
/// \param collector Collector for the profile data from experiments
/// \return cb::Error object indicating success or failure.
static cb::Error Create(
const bool verbose, const double stability_threshold,
Expand All @@ -236,7 +235,7 @@ class InferenceProfiler {
uint64_t measurement_request_count, MeasurementMode measurement_mode,
std::shared_ptr<MPIDriver> mpi_driver, const uint64_t metrics_interval_ms,
const bool should_collect_metrics, const double overhead_pct_threshold,
const std::shared_ptr<RawDataCollector> collector);
const std::shared_ptr<ProfileDataCollector> collector);

/// Performs the profiling on the given range with the given search algorithm.
/// For profiling using request rate invoke template with double, otherwise
Expand Down Expand Up @@ -319,7 +318,7 @@ class InferenceProfiler {
MeasurementMode measurement_mode, std::shared_ptr<MPIDriver> mpi_driver,
const uint64_t metrics_interval_ms, const bool should_collect_metrics,
const double overhead_pct_threshold,
const std::shared_ptr<RawDataCollector> collector);
const std::shared_ptr<ProfileDataCollector> collector);

/// Actively measure throughput in every 'measurement_window' msec until the
/// throughput is stable. Once the throughput is stable, it adds the
Expand Down Expand Up @@ -458,7 +457,7 @@ class InferenceProfiler {
std::vector<RequestRecord>& valid_requests);

/// Add the data from the request records to the Raw Data Collector
/// \param perf_status Perf_status of the current measurement
/// \param perf_status PerfStatus of the current measurement
/// \param window_start_ns The window start timestamp in nanoseconds.
/// \param window_end_ns The window end timestamp in nanoseconds.
/// \param request_records The request records to collect.
Expand Down Expand Up @@ -688,7 +687,7 @@ class InferenceProfiler {
std::shared_ptr<ModelParser> parser_;
std::shared_ptr<cb::ClientBackend> profile_backend_;
std::unique_ptr<LoadManager> manager_;
std::shared_ptr<RawDataCollector> collector_;
std::shared_ptr<ProfileDataCollector> collector_;
LoadParams load_parameters_;

bool include_lib_stats_;
Expand Down
17 changes: 9 additions & 8 deletions src/c++/perf_analyzer/perf_analyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ PerfAnalyzer::Run()
PrerunReport();
Profile();
WriteReport();
GenerateProfileExportReport();
GenerateProfileExport();
Finalize();
}

Expand Down Expand Up @@ -255,12 +255,12 @@ PerfAnalyzer::CreateAnalyzerObjects()
params_->sequence_length_specified, params_->sequence_length_variation);

FAIL_IF_ERR(
pa::RawDataCollector::Create(&collector_),
"failed to create data collector");
pa::ProfileDataCollector::Create(&collector_),
"failed to create profile data collector");

FAIL_IF_ERR(
pa::RawDataReporter::Create(&reporter_),
"failed to create data reporter");
pa::ProfileDataExporter::Create(&exporter_),
"failed to create profile data exporter");

FAIL_IF_ERR(
pa::InferenceProfiler::Create(
Expand Down Expand Up @@ -432,11 +432,12 @@ PerfAnalyzer::WriteReport()
}

void
PerfAnalyzer::GenerateProfileExportReport()
PerfAnalyzer::GenerateProfileExport()
{
if (!params_->profile_export_file.empty()) {
reporter_->ConvertToJson(collector_->GetData(), collector_->GetVersion());
reporter_->OutputToFile(params_->profile_export_file);
exporter_->Export(
collector_->GetData(), collector_->GetVersion(),
params_->profile_export_file);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/c++/perf_analyzer/perf_analyzer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -37,8 +37,8 @@
#include "model_parser.h"
#include "mpi_utils.h"
#include "perf_utils.h"
#include "raw_data_collector.h"
#include "raw_data_reporter.h"
#include "profile_data_collector.h"
#include "profile_data_exporter.h"

// Perf Analyzer provides various metrics to measure the performance of
// the inference server. It can either be used to measure the throughput,
Expand Down Expand Up @@ -184,8 +184,8 @@ class PerfAnalyzer {
std::unique_ptr<cb::ClientBackend> backend_;
std::shared_ptr<pa::ModelParser> parser_;
std::vector<pa::PerfStatus> perf_statuses_;
std::shared_ptr<pa::RawDataCollector> collector_;
std::shared_ptr<pa::RawDataReporter> reporter_;
std::shared_ptr<pa::ProfileDataCollector> collector_;
std::shared_ptr<pa::ProfileDataExporter> exporter_;

//
// Helper methods
Expand All @@ -197,6 +197,6 @@ class PerfAnalyzer {
void PrerunReport();
void Profile();
void WriteReport();
void GenerateProfileExportReport();
void GenerateProfileExport();
void Finalize();
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "raw_data_collector.h"
#include "profile_data_collector.h"

#include <memory>

Expand All @@ -33,18 +33,19 @@
namespace triton { namespace perfanalyzer {

cb::Error
RawDataCollector::Create(std::shared_ptr<RawDataCollector>* collector)
ProfileDataCollector::Create(std::shared_ptr<ProfileDataCollector>* collector)
{
std::shared_ptr<RawDataCollector> local_collector{new RawDataCollector()};
std::shared_ptr<ProfileDataCollector> local_collector{
new ProfileDataCollector()};
*collector = std::move(local_collector);
return cb::Error::Success;
}

void
RawDataCollector::AddWindow(
PerfMode& id, uint64_t window_start_ns, uint64_t window_end_ns)
ProfileDataCollector::AddWindow(
InferenceLoadMode& id, uint64_t window_start_ns, uint64_t window_end_ns)
{
auto it = FindEntry(id);
auto it = FindExperiment(id);

if (it == experiments_.end()) {
Experiment new_experiment{};
Expand All @@ -64,10 +65,10 @@ RawDataCollector::AddWindow(
}

void
RawDataCollector::AddData(
PerfMode& id, std::vector<RequestRecord>&& request_records)
ProfileDataCollector::AddData(
InferenceLoadMode& id, std::vector<RequestRecord>&& request_records)
{
auto it = FindEntry(id);
auto it = FindExperiment(id);

if (it == experiments_.end()) {
Experiment new_experiment{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,63 +37,70 @@

namespace triton { namespace perfanalyzer {

struct PerfMode {
/// Data structure to hold which inference load mode was used for an experiment.
/// Only one data member will be nonzero, indicating the inference load mode for
/// a particular experiment.
struct InferenceLoadMode {
uint32_t concurrency;
double request_rate;

PerfMode()
InferenceLoadMode()
{
concurrency = 0;
request_rate = 0.0;
}

PerfMode(uint64_t c, double rr)
InferenceLoadMode(uint64_t c, double rr)
{
concurrency = c;
request_rate = rr;
}

bool operator==(const PerfMode& rhs) const
bool operator==(const InferenceLoadMode& rhs) const
{
return (concurrency == rhs.concurrency) &&
(request_rate == rhs.request_rate);
}
};

/// Data structure to hold profile export data for an experiment (e.g.
/// concurrency 4 or request rate 50)
struct Experiment {
PerfMode mode;
InferenceLoadMode mode;
std::vector<RequestRecord> requests;
std::vector<uint64_t> window_boundaries;
};

class RawDataCollector {
/// Data structure and methods for storing profile export data.
class ProfileDataCollector {
public:
static cb::Error Create(std::shared_ptr<RawDataCollector>* collector);
~RawDataCollector() = default;
static cb::Error Create(std::shared_ptr<ProfileDataCollector>* collector);
~ProfileDataCollector() = default;


/// Add a measurement window to the collector
/// \param id Identifier for the experiment
/// \param window_start_ns The window start timestamp in nanoseconds.
/// \param window_end_ns The window end timestamp in nanoseconds.
void AddWindow(
PerfMode& id, uint64_t window_start_ns, uint64_t window_end_ns);
InferenceLoadMode& id, uint64_t window_start_ns, uint64_t window_end_ns);

/// Add request records to an experiment
/// @param id Identifier for the experiment
/// @param request_records The request information for the current experiment.
void AddData(PerfMode& id, std::vector<RequestRecord>&& request_records);
void AddData(
InferenceLoadMode& id, std::vector<RequestRecord>&& request_records);

/// Get the raw experiment data for the profile
/// @return Raw experiment data
/// Get the experiment data for the profile
/// @return Experiment data
std::vector<Experiment>& GetData() { return experiments_; }

std::string& GetVersion() { return version_; }

private:
RawDataCollector() = default;
ProfileDataCollector() = default;

std::vector<Experiment>::iterator FindEntry(PerfMode& id)
std::vector<Experiment>::iterator FindExperiment(InferenceLoadMode& id)
{
return std::find_if(
experiments_.begin(), experiments_.end(),
Expand Down
Loading

0 comments on commit 2f7b455

Please sign in to comment.