Skip to content

Commit

Permalink
Reformat to use camel case
Browse files Browse the repository at this point in the history
  • Loading branch information
debermudez committed Jun 8, 2022
1 parent abb3141 commit e98256f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 49 deletions.
78 changes: 35 additions & 43 deletions src/c++/perf_analyzer/inference_profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,9 @@ InferenceProfiler::ProfileHelper(
}
}

*is_stable = determine_stability(load_status);
*is_stable = determineStability(load_status);

if (is_done_profiling(load_status, is_stable)) {
if (isDoneProfiling(load_status, is_stable)) {
break;
}

Expand All @@ -663,7 +663,7 @@ InferenceProfiler::ProfileHelper(
}

bool
InferenceProfiler::determine_stability(LoadStatus& load_status)
InferenceProfiler::determineStability(LoadStatus& load_status)
{
bool stable = false;
if (load_status.infer_per_sec.size() >= load_parameters_.stability_window) {
Expand All @@ -677,21 +677,20 @@ InferenceProfiler::determine_stability(LoadStatus& load_status)
}
}

stable = stable && check_window_for_stability(idx, load_status);
stable = stable && checkWindowForStability(idx, load_status);
}
return stable;
}

bool
InferenceProfiler::check_window_for_stability(
size_t idx, LoadStatus& load_status)
InferenceProfiler::checkWindowForStability(size_t idx, LoadStatus& load_status)
{
return is_infer_window_stable(idx, load_status) &&
is_latency_window_stable(idx, load_status);
return isInferWindowStable(idx, load_status) &&
isLatencyWindowStable(idx, load_status);
}

bool
InferenceProfiler::is_infer_window_stable(size_t idx, LoadStatus& load_status)
InferenceProfiler::isInferWindowStable(size_t idx, LoadStatus& load_status)
{
auto infer_start = std::begin(load_status.infer_per_sec) + idx;
auto infer_per_sec_measurements = std::minmax_element(
Expand All @@ -705,7 +704,7 @@ InferenceProfiler::is_infer_window_stable(size_t idx, LoadStatus& load_status)
}

bool
InferenceProfiler::is_latency_window_stable(size_t idx, LoadStatus& load_status)
InferenceProfiler::isLatencyWindowStable(size_t idx, LoadStatus& load_status)
{
auto latency_start = std::begin(load_status.latencies) + idx;
auto latencies_per_sec_measurements = std::minmax_element(
Expand All @@ -718,15 +717,15 @@ InferenceProfiler::is_latency_window_stable(size_t idx, LoadStatus& load_status)
}

bool
InferenceProfiler::is_done_profiling(LoadStatus& load_status, bool* is_stable)
InferenceProfiler::isDoneProfiling(LoadStatus& load_status, bool* is_stable)
{
size_t idx =
load_status.infer_per_sec.size() - load_parameters_.stability_window;
bool within_threshold = true;
bool done = false;

for (size_t i = idx; i < load_status.infer_per_sec.size(); i++) {
within_threshold &= check_within_threshold(idx, load_status);
within_threshold &= checkWithinThreshold(idx, load_status);
}

if (mpi_driver_->IsMPIRun()) {
Expand All @@ -743,7 +742,7 @@ InferenceProfiler::is_done_profiling(LoadStatus& load_status, bool* is_stable)
}

bool
InferenceProfiler::check_within_threshold(size_t idx, LoadStatus& load_status)
InferenceProfiler::checkWithinThreshold(size_t idx, LoadStatus& load_status)
{
return load_status.latencies[idx] < (latency_threshold_ms_ * 1000 * 1000);
}
Expand Down Expand Up @@ -1396,37 +1395,37 @@ InferenceProfiler::AllMPIRanksAreStable(bool current_rank_stability)
#ifndef DOCTEST_CONFIG_DISABLE
class TestInferenceProfiler {
public:
static bool test_check_within_threshold(
static bool testCheckWithinThreshold(
LoadStatus& ls, LoadParams& lp, uint64_t latency_threshold_ms)
{
InferenceProfiler ip;
size_t idx = ls.infer_per_sec.size() - lp.stability_window;
ip.latency_threshold_ms_ = latency_threshold_ms;

return ip.check_within_threshold(idx, ls);
return ip.checkWithinThreshold(idx, ls);
}

static bool test_check_window_for_stability(LoadStatus& ls, LoadParams& lp)
static bool testCheckWindowForStability(LoadStatus& ls, LoadParams& lp)
{
size_t idx = ls.infer_per_sec.size() - lp.stability_window;

InferenceProfiler ip;
ip.load_parameters_.stability_threshold = lp.stability_threshold;
ip.load_parameters_.stability_window = lp.stability_window;

return ip.check_window_for_stability(idx, ls);
return ip.checkWindowForStability(idx, ls);
};

static bool test_determine_stability(LoadStatus& ls, LoadParams& lp)
static bool testDetermineStability(LoadStatus& ls, LoadParams& lp)
{
InferenceProfiler ip;
ip.load_parameters_.stability_threshold = lp.stability_threshold;
ip.load_parameters_.stability_window = lp.stability_window;

return ip.determine_stability(ls);
return ip.determineStability(ls);
}

static bool test_is_done_profiling(
static bool testIsDoneProfiling(
LoadStatus& ls, LoadParams& lp, uint64_t latency_threshold_ms)
{
InferenceProfiler ip;
Expand All @@ -1435,8 +1434,8 @@ class TestInferenceProfiler {
ip.latency_threshold_ms_ = latency_threshold_ms;
ip.mpi_driver_ = std::make_shared<triton::perfanalyzer::MPIDriver>(false);

bool is_stable = ip.determine_stability(ls);
return ip.is_done_profiling(ls, &is_stable);
bool is_stable = ip.determineStability(ls);
return ip.isDoneProfiling(ls, &is_stable);
};
};

Expand All @@ -1451,46 +1450,39 @@ TEST_CASE("test_check_window_for_stability")
ls.latencies = {1, 1, 1};
lp.stability_window = 3;
lp.stability_threshold = 0.1;
CHECK(
TestInferenceProfiler::test_check_window_for_stability(ls, lp) ==
false);
CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == false);
}
SUBCASE("test throughput stable")
{
ls.infer_per_sec = {500.0, 520.0, 510.0};
ls.latencies = {1, 1, 1};
lp.stability_window = 3;
lp.stability_threshold = 0.1;
CHECK(
TestInferenceProfiler::test_check_window_for_stability(ls, lp) == true);
CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == true);
}
SUBCASE("test latency not stable")
{
ls.infer_per_sec = {500.0, 520.0, 510.0};
ls.latencies = {1, 100, 50};
lp.stability_window = 3;
lp.stability_threshold = 0.1;
CHECK(
TestInferenceProfiler::test_check_window_for_stability(ls, lp) ==
false);
CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == false);
}
SUBCASE("test latency stable")
{
ls.infer_per_sec = {500.0, 520.0, 510.0};
ls.latencies = {45, 50, 45};
lp.stability_window = 3;
lp.stability_threshold = 0.1;
CHECK(
TestInferenceProfiler::test_check_window_for_stability(ls, lp) == true);
CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == true);
}
SUBCASE("test throughput stable after many measurements")
{
ls.infer_per_sec = {1.0, 1000.0, 500.0, 1500.0, 500.0, 520.0, 510.0};
ls.latencies = {1, 1, 1, 1, 1, 1, 1};
lp.stability_window = 3;
lp.stability_threshold = 0.1;
CHECK(
TestInferenceProfiler::test_check_window_for_stability(ls, lp) == true);
CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == true);
}
}

Expand All @@ -1508,15 +1500,15 @@ TEST_CASE("test check within threshold")
{
ls.latencies = {2000000, 2000000, 2000000};
CHECK(
TestInferenceProfiler::test_check_within_threshold(
TestInferenceProfiler::testCheckWithinThreshold(
ls, lp, latency_threshold_ms) == false);
}

SUBCASE("test within threshold")
{
ls.latencies = {100000, 100000, 100000};
CHECK(
TestInferenceProfiler::test_check_within_threshold(
TestInferenceProfiler::testCheckWithinThreshold(
ls, lp, latency_threshold_ms) == true);
}
}
Expand All @@ -1533,10 +1525,10 @@ TEST_CASE("test_determine_stability")
lp.stability_window = 3;
lp.stability_threshold = 0.1;
uint64_t latency_threshold_ms = 1;
CHECK(TestInferenceProfiler::test_determine_stability(ls, lp) == false);
CHECK(TestInferenceProfiler::testDetermineStability(ls, lp) == false);

ls.infer_per_sec = {500.0, 520.0, 510.0};
CHECK(TestInferenceProfiler::test_determine_stability(ls, lp) == true);
CHECK(TestInferenceProfiler::testDetermineStability(ls, lp) == true);
}
}

Expand All @@ -1555,7 +1547,7 @@ TEST_CASE("test_is_done_profiling")
uint64_t latency_threshold_ms = NO_LIMIT;

CHECK(
TestInferenceProfiler::test_is_done_profiling(
TestInferenceProfiler::testIsDoneProfiling(
ls, lp, latency_threshold_ms) == false);
}

Expand All @@ -1568,7 +1560,7 @@ TEST_CASE("test_is_done_profiling")
uint64_t latency_threshold_ms = NO_LIMIT;

CHECK(
TestInferenceProfiler::test_is_done_profiling(
TestInferenceProfiler::testIsDoneProfiling(
ls, lp, latency_threshold_ms) == false);
}

Expand All @@ -1581,7 +1573,7 @@ TEST_CASE("test_is_done_profiling")
lp.stability_threshold = 0.1;
uint64_t latency_threshold_ms = 1;
CHECK(
TestInferenceProfiler::test_is_done_profiling(
TestInferenceProfiler::testIsDoneProfiling(
ls, lp, latency_threshold_ms) == true);
}

Expand All @@ -1594,12 +1586,12 @@ TEST_CASE("test_is_done_profiling")
uint64_t latency_threshold_ms = 1;

CHECK(
TestInferenceProfiler::test_is_done_profiling(
TestInferenceProfiler::testIsDoneProfiling(
ls, lp, latency_threshold_ms) == false);
ls.infer_per_sec = {500.0, 520.0, 510.0};

CHECK(
TestInferenceProfiler::test_is_done_profiling(
TestInferenceProfiler::testIsDoneProfiling(
ls, lp, latency_threshold_ms) == true);
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/c++/perf_analyzer/inference_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,41 +333,41 @@ class InferenceProfiler {
/// A helper function to determine if profiling is stable
/// \param load_status Stores the observations of infer_per_sec and latencies
/// \return Returns if the threshold and latencies are stable.
bool determine_stability(LoadStatus& load_status);
bool determineStability(LoadStatus& load_status);

/// Check if latency at index idx is within the latency threshold
/// \param idx index in latency vector
/// \param load_status Stores the observations of infer_per_sec and latencies
/// \return Returns whether the latencies are below the max threshold
bool check_within_threshold(size_t idx, LoadStatus& load_status);
bool checkWithinThreshold(size_t idx, LoadStatus& load_status);

/// A helper function to determine if profiling is done
/// \param load_status Stores the observations of infer_per_sec and latencies
/// \param is_stable Returns whether the measurement stabilized or not.
/// \return Returns if we should break out of the infinite stability check
/// loop.
bool is_done_profiling(LoadStatus& load_status, bool* is_stable);
bool isDoneProfiling(LoadStatus& load_status, bool* is_stable);

/// Check if observed inferences and latencies are within threshold
/// for a single window starting at idx
/// \param idx index in latency vector
/// \param load_status Stores the observations of infer_per_sec and latencies
/// \return Returns whether inference and latency are stable
bool check_window_for_stability(size_t idx, LoadStatus& load_status);
bool checkWindowForStability(size_t idx, LoadStatus& load_status);

/// Check if observed inferences are within threshold
/// for a single window starting at idx
/// \param idx index in latency vector
/// \param load_status Stores the observations of infer_per_sec and latencies
/// \return Returns whether inference is stable
bool is_infer_window_stable(size_t idx, LoadStatus& load_status);
bool isInferWindowStable(size_t idx, LoadStatus& load_status);

/// Check if observed latencies are within threshold
/// for a single window starting at idx
/// \param idx index in latency vector
/// \param load_status Stores the observations of infer_per_sec and latencies
/// \return Returns whether latency is stable
bool is_latency_window_stable(size_t idx, LoadStatus& load_status);
bool isLatencyWindowStable(size_t idx, LoadStatus& load_status);

/// Helper function to perform measurement.
/// \param status_summary The summary of this measurement.
Expand Down

0 comments on commit e98256f

Please sign in to comment.