Skip to content

[ML] Add resource monitoring in CBucketGatherer::addEventData #2848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
=== Enhancements

* Track memory used in the hierarchical results normalizer. (See {ml-pull}2831[#2831].)
* Improve adherence to memory limits for the bucket gatherer. (See {ml-pull}2848[#2848].)

=== Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion include/model/CBucketGatherer.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class MODEL_EXPORT CBucketGatherer {
CResourceMonitor& resourceMonitor) = 0;

//! Record the arrival of \p data at \p time.
bool addEventData(CEventData& data);
bool addEventData(CEventData& data, CResourceMonitor& resourceMonitor);

//! Roll time forwards to \p time.
void timeNow(core_t::TTime time);
Expand Down
5 changes: 3 additions & 2 deletions lib/model/CBucketGatherer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <algorithm>
#include <map>
#include <model/CResourceMonitor.h>

namespace ml {
namespace model {
Expand Down Expand Up @@ -230,7 +231,7 @@ CBucketGatherer::CBucketGatherer(bool isForPersistence, const CBucketGatherer& o
}
}

bool CBucketGatherer::addEventData(CEventData& data) {
bool CBucketGatherer::addEventData(CEventData& data, CResourceMonitor& resourceMonitor) {
core_t::TTime time = data.time();

if (time < this->earliestBucketStartTime()) {
Expand Down Expand Up @@ -293,7 +294,7 @@ bool CBucketGatherer::addEventData(CEventData& data) {
if (influence) {
const std::string& inf = *influence;
canonicalInfluences[i] = inf;
if (count > 0) {
if (count > 0 && resourceMonitor.areAllocationsAllowed()) {
influencerCounts[i]
.emplace(boost::unordered::piecewise_construct,
boost::make_tuple(pidCid, inf),
Expand Down
2 changes: 1 addition & 1 deletion lib/model/CDataGatherer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ bool CDataGatherer::addArrival(const TStrCPtrVec& fieldValues,
return false;
}

return m_BucketGatherer->addEventData(data);
return m_BucketGatherer->addEventData(data, resourceMonitor);
}

void CDataGatherer::sampleNow(core_t::TTime sampleBucketStart) {
Expand Down