Skip to content

Commit 413d412

Browse files
authored
[ML] Pad estimated memory usage in anticipation of multi-bucket analysis (#173)
1 parent b75c786 commit 413d412

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

lib/api/unittest/CAnomalyJobLimitTest.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,10 @@ void CAnomalyJobLimitTest::testModelledEntityCountForFixedMemoryLimit() {
392392
LOG_DEBUG(<< "Memory status = " << used.s_MemoryStatus);
393393
LOG_DEBUG(<< "Memory usage bytes = " << used.s_Usage);
394394
LOG_DEBUG(<< "Memory limit bytes = " << memoryLimit * 1024 * 1024);
395-
CPPUNIT_ASSERT(used.s_ByFields > 650 && used.s_ByFields < 850);
395+
CPPUNIT_ASSERT(used.s_ByFields > 550 && used.s_ByFields < 750);
396396
CPPUNIT_ASSERT_EQUAL(std::size_t(2), used.s_PartitionFields);
397397
CPPUNIT_ASSERT_DOUBLES_EQUAL(memoryLimit * 1024 * 1024 / 2, used.s_Usage,
398-
memoryLimit * 1024 * 1024 / 33); // Within 6%.
398+
memoryLimit * 1024 * 1024 / 20); // Within 10%.
399399
}
400400

401401
LOG_DEBUG(<< "**** Test partition ****");
@@ -438,7 +438,7 @@ void CAnomalyJobLimitTest::testModelledEntityCountForFixedMemoryLimit() {
438438
LOG_DEBUG(<< "# partition = " << used.s_PartitionFields);
439439
LOG_DEBUG(<< "Memory status = " << used.s_MemoryStatus);
440440
LOG_DEBUG(<< "Memory usage = " << used.s_Usage);
441-
CPPUNIT_ASSERT(used.s_PartitionFields > 370 && used.s_PartitionFields < 470);
441+
CPPUNIT_ASSERT(used.s_PartitionFields > 300 && used.s_PartitionFields < 400);
442442
CPPUNIT_ASSERT(static_cast<double>(used.s_ByFields) >
443443
0.97 * static_cast<double>(used.s_PartitionFields));
444444
CPPUNIT_ASSERT_DOUBLES_EQUAL(memoryLimit * 1024 * 1024 / 2, used.s_Usage,

lib/maths/CTimeSeriesModel.cc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,14 @@ void CUnivariateTimeSeriesModel::debugMemoryUsage(core::CMemoryUsage::TMemoryUsa
11671167
mem->setName("CUnivariateTimeSeriesModel");
11681168
core::CMemoryDebug::dynamicSize("m_Controllers", m_Controllers, mem);
11691169
core::CMemoryDebug::dynamicSize("m_TrendModel", m_TrendModel, mem);
1170+
// We made various memory improvements in 6.4 partly in preparation for multi-bucket
1171+
// analysis. This is not going to be available until 6.5; however, we will account for
1172+
// its memory now. The memory usage is used, for example, to allocate jobs to nodes and
1173+
// to decide if there is sufficient memory to create jobs. Operationally, we therefore
1174+
// want to avoid unnecessary changes in model memory between versions. An extra residual
1175+
// model is a good proxy for the amount of memory multi-bucket will consume.
11701176
core::CMemoryDebug::dynamicSize("m_ResidualModel", m_ResidualModel, mem);
1177+
core::CMemoryDebug::dynamicSize("m_ResidualModelPad", m_ResidualModel, mem);
11711178
core::CMemoryDebug::dynamicSize("m_AnomalyModel", m_AnomalyModel, mem);
11721179
core::CMemoryDebug::dynamicSize("m_ChangeDetector", m_ChangeDetector, mem);
11731180
core::CMemoryDebug::dynamicSize("m_SlidingWindow", m_SlidingWindow, mem);
@@ -1176,7 +1183,8 @@ void CUnivariateTimeSeriesModel::debugMemoryUsage(core::CMemoryUsage::TMemoryUsa
11761183
std::size_t CUnivariateTimeSeriesModel::memoryUsage() const {
11771184
return core::CMemory::dynamicSize(m_Controllers) +
11781185
core::CMemory::dynamicSize(m_TrendModel) +
1179-
core::CMemory::dynamicSize(m_ResidualModel) +
1186+
/*see above*/
1187+
2 * core::CMemory::dynamicSize(m_ResidualModel) +
11801188
core::CMemory::dynamicSize(m_AnomalyModel) +
11811189
core::CMemory::dynamicSize(m_ChangeDetector) +
11821190
core::CMemory::dynamicSize(m_SlidingWindow);
@@ -2440,15 +2448,23 @@ void CMultivariateTimeSeriesModel::debugMemoryUsage(core::CMemoryUsage::TMemoryU
24402448
mem->setName("CUnivariateTimeSeriesModel");
24412449
core::CMemoryDebug::dynamicSize("m_Controllers", m_Controllers, mem);
24422450
core::CMemoryDebug::dynamicSize("m_TrendModel", m_TrendModel, mem);
2451+
// We made various memory improvements in 6.4 partly in preparation for multi-bucket
2452+
// analysis. This is not going to be available until 6.5; however, we will account for
2453+
// its memory now. The memory usage is used, for example, to allocate jobs to nodes and
2454+
// to decide if there is sufficient memory to create jobs. Operationally, we therefore
2455+
// want to avoid unnecessary changes in model memory between versions. An extra residual
2456+
// model is a good proxy for the amount of memory multi-bucket will consume.
24432457
core::CMemoryDebug::dynamicSize("m_ResidualModel", m_ResidualModel, mem);
2458+
core::CMemoryDebug::dynamicSize("m_ResidualModelPad", m_ResidualModel, mem);
24442459
core::CMemoryDebug::dynamicSize("m_AnomalyModel", m_AnomalyModel, mem);
24452460
core::CMemoryDebug::dynamicSize("m_SlidingWindow", m_SlidingWindow, mem);
24462461
}
24472462

24482463
std::size_t CMultivariateTimeSeriesModel::memoryUsage() const {
24492464
return core::CMemory::dynamicSize(m_Controllers) +
24502465
core::CMemory::dynamicSize(m_TrendModel) +
2451-
core::CMemory::dynamicSize(m_ResidualModel) +
2466+
/*see above*/
2467+
2 * core::CMemory::dynamicSize(m_ResidualModel) +
24522468
core::CMemory::dynamicSize(m_AnomalyModel) +
24532469
core::CMemory::dynamicSize(m_SlidingWindow);
24542470
}

0 commit comments

Comments
 (0)