-
Notifications
You must be signed in to change notification settings - Fork 57
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
Deduplicate the "other sets" in a LocalVocab
#1632
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f78f64d
Swap out vector with hash set
RobinTF f043718
Merge branch 'master' into merged-vocab
RobinTF b7d11f9
Add unit test
RobinTF 6baa009
Fix size calculation and add unit test
RobinTF 6fafb83
Fix a sonarcloud issue
joka921 57cef0f
Merge branch 'master' into merged-vocab
RobinTF 7865102
Add basic vocab size tracking
RobinTF 4e61b01
Fix formatting
RobinTF ae493b4
Merge branch 'master' into merged-vocab
RobinTF 01388d3
Fix sonarcloud issues
RobinTF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,41 @@ | |
|
||
#include "engine/Operation.h" | ||
|
||
#include <absl/cleanup/cleanup.h> | ||
|
||
#include "engine/QueryExecutionTree.h" | ||
#include "global/RuntimeParameters.h" | ||
#include "util/OnDestructionDontThrowDuringStackUnwinding.h" | ||
#include "util/TransparentFunctors.h" | ||
|
||
using namespace std::chrono_literals; | ||
|
||
namespace { | ||
// Keep track of some statistics about the local vocabs of the results. | ||
struct LocalVocabTracking { | ||
size_t maxSize_ = 0; | ||
size_t sizeSum_ = 0; | ||
size_t totalVocabs_ = 0; | ||
size_t nonEmptyVocabs_ = 0; | ||
|
||
float avgSize() const { | ||
return nonEmptyVocabs_ == 0 ? 0 | ||
: static_cast<float>(sizeSum_) / | ||
static_cast<float>(nonEmptyVocabs_); | ||
} | ||
}; | ||
|
||
// Merge the stats of a single local vocab into the overall stats. | ||
void mergeStats(LocalVocabTracking& stats, const LocalVocab& vocab) { | ||
stats.maxSize_ = std::max(stats.maxSize_, vocab.size()); | ||
stats.sizeSum_ += vocab.size(); | ||
++stats.totalVocabs_; | ||
if (!vocab.empty()) { | ||
++stats.nonEmptyVocabs_; | ||
} | ||
} | ||
} // namespace | ||
|
||
//______________________________________________________________________________ | ||
template <typename F> | ||
void Operation::forAllDescendants(F f) { | ||
|
@@ -132,23 +160,33 @@ ProtoResult Operation::runComputation(const ad_utility::Timer& timer, | |
// correctly because the result was computed, so we can pass `nullopt` as | ||
// the last argument. | ||
if (result.isFullyMaterialized()) { | ||
size_t numLocalVocabs = result.localVocab().numSets(); | ||
if (numLocalVocabs > 1) { | ||
runtimeInfo().addDetail("num-local-vocabs", numLocalVocabs); | ||
size_t vocabSize = result.localVocab().size(); | ||
if (vocabSize > 1) { | ||
runtimeInfo().addDetail("local-vocab-size", vocabSize); | ||
} | ||
updateRuntimeInformationOnSuccess(result.idTable().size(), | ||
ad_utility::CacheStatus::computed, | ||
timer.msecs(), std::nullopt); | ||
} else { | ||
runtimeInfo().status_ = RuntimeInformation::lazilyMaterialized; | ||
result.runOnNewChunkComputed( | ||
[this, timeSizeUpdate = 0us]( | ||
const IdTable& idTable, | ||
[this, timeSizeUpdate = 0us, vocabStats = LocalVocabTracking{}]( | ||
const Result::IdTableVocabPair& pair, | ||
std::chrono::microseconds duration) mutable { | ||
const IdTable& idTable = pair.idTable_; | ||
updateRuntimeStats(false, idTable.numRows(), idTable.numColumns(), | ||
duration); | ||
LOG(DEBUG) << "Computed partial chunk of size " << idTable.numRows() | ||
<< " x " << idTable.numColumns() << std::endl; | ||
mergeStats(vocabStats, pair.localVocab_); | ||
if (vocabStats.sizeSum_ > 0) { | ||
runtimeInfo().addDetail( | ||
"non-empty-local-vocabs", | ||
absl::StrCat(vocabStats.nonEmptyVocabs_, " / ", | ||
vocabStats.totalVocabs_, | ||
", Ø = ", vocabStats.avgSize(), | ||
", max = ", vocabStats.maxSize_)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also the number of contained sets (similar statistics, max/avg) would be good to know here. |
||
} | ||
timeSizeUpdate += duration; | ||
if (timeSizeUpdate > 50ms) { | ||
timeSizeUpdate = 0us; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also want the number of non-local-vocabs that are merged together in the materialized local vocab here (if it is greater than >1
), so
local-vocab-num-sets` would be a nice name here.