Skip to content
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

Correctly record the rawBytesRead_ metric in TableScan #8147

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions velox/dwio/common/CacheInputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ void CacheInputStream::loadPosition() {
// 'region_'
loadRegion.length = std::min<int32_t>(
loadQuantum_, region_.length - (loadRegion.offset - region_.offset));

// There is no need to update the metric in the loadData method because
// loadSync is always executed regardless and updates the metric.
loadSync(loadRegion);
}
auto* entry = pin_.checkedEntry();
Expand Down
1 change: 1 addition & 0 deletions velox/dwio/common/DirectBufferedInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ std::vector<cache::CachePin> DirectCoalescedLoad::loadData(bool isPrefetch) {
}
input_->read(buffers, requests_[0].region.offset, LogType::FILE);
ioStats_->read().increment(size);
ioStats_->incRawBytesRead(size - overread);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JkSelf Can you also fix this in DwioCoalescedLoadBase::updateStats? Thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yuhta The rawBytesRead already updated in loadSync and loadData. It seems no need updated in DwioCoalescedLoadBase::updateStats.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is it updated in DwioCoalescedLoad::loadData and SsdLoad::loadData? I cannot find it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the code and found that the update of rawBytesRead for CachedInputBuffer is done in the loadSync function. loadSync is executed unconditionally after loadOrFuture here. However, in the case of DirectInputBuffer, the execution of loadSync is conditional here, so we need to update rawBytesRead in the loadData function instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yuhta Do you have any further comment? Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. Can you add comment to those 2 places saying the counter is increased in loadSync unconditionally so we don't need to do it in loadData?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yuhta Added the comments. Please help to review again. Thanks.

ioStats_->incRawOverreadBytes(overread);
if (isPrefetch) {
ioStats_->prefetch().increment(size);
Expand Down
3 changes: 3 additions & 0 deletions velox/dwio/common/DirectInputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ void DirectInputStream::loadPosition() {
loadedRegion_.length = (offsetInRegion_ + loadQuantum_ <= region_.length)
? loadQuantum_
: (region_.length - offsetInRegion_);

// Since the loadSync method updates the metric, but it is conditionally
// executed, we also need to update the metric in the loadData method.
loadSync();
}

Expand Down
3 changes: 2 additions & 1 deletion velox/exec/tests/TableScanTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ TEST_F(TableScanTest, allColumns) {
auto scanNodeId = plan->id();
auto it = planStats.find(scanNodeId);
ASSERT_TRUE(it != planStats.end());
ASSERT_TRUE(it->second.peakMemoryBytes > 0);
ASSERT_GT(it->second.peakMemoryBytes, 0);
ASSERT_GT(it->second.rawInputBytes, 0);
EXPECT_LT(0, exec::TableScan::ioWaitNanos());
}

Expand Down