Skip to content

Commit

Permalink
Make callbacks to pass std::chrono::high_resolution_clock::duration i…
Browse files Browse the repository at this point in the history
…nstead

Summary:
X-link: facebookincubator/velox#9566

As said

Reviewed By: kgpai, Magoja

Differential Revision: D56430332

fbshipit-source-id: 6c6698bf82c9075930630974f48d911a5b62ea8a
  • Loading branch information
Daniel Munoz authored and facebook-github-bot committed Apr 23, 2024
1 parent 8d84734 commit bb0fa53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 7 additions & 7 deletions dwio/nimble/velox/VeloxReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "dwio/nimble/velox/VeloxReader.h"
#include <chrono>
#include <cstdint>
#include <optional>
#include <vector>
Expand Down Expand Up @@ -260,8 +261,9 @@ void VeloxReader::loadStripe() {
metrics.rowsInStripe = rowsRemainingInStripe_;
metrics.cpuUsec = timing.cpuNanos / 1000;
metrics.wallTimeUsec = timing.wallNanos / 1000;
if (parameters_.blockedOnIoMsCallback) {
parameters_.blockedOnIoMsCallback(timing.wallNanos / 1000000);
if (parameters_.blockedOnIoCallback) {
parameters_.blockedOnIoCallback(
std::chrono::nanoseconds{timing.wallNanos});
}
logger_->logStripeLoad(metrics);
} catch (const std::exception& e) {
Expand All @@ -285,7 +287,7 @@ bool VeloxReader::next(uint64_t rowCount, velox::VectorPtr& result) {
}
uint64_t rowsToRead = std::min(rowsRemainingInStripe_, rowCount);
std::optional<std::chrono::steady_clock::time_point> startTime;
if (parameters_.decodingTimeUsCallback) {
if (parameters_.decodingTimeCallback) {
startTime = std::chrono::steady_clock::now();
}
rootReader_->next(rowsToRead, result, nullptr /*scatterBitmap*/);
Expand All @@ -294,10 +296,8 @@ bool VeloxReader::next(uint64_t rowCount, velox::VectorPtr& result) {
barrier_->waitAll();
}
if (startTime.has_value()) {
parameters_.decodingTimeUsCallback(
std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::steady_clock::now() - startTime.value())
.count());
parameters_.decodingTimeCallback(
std::chrono::steady_clock::now() - startTime.value());
}

// Update reader state
Expand Down
6 changes: 4 additions & 2 deletions dwio/nimble/velox/VeloxReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ struct VeloxReadParams : public FieldReaderParams {
std::function<void(uint32_t)> stripeCountCallback;

// Report the Wall time (ms) that we're blocked waiting on IO.
std::function<void(uint64_t)> blockedOnIoMsCallback;
std::function<void(std::chrono::high_resolution_clock::duration)>
blockedOnIoCallback;

// Report the Wall time (us) that we spend decoding.
std::function<void(uint64_t)> decodingTimeUsCallback;
std::function<void(std::chrono::high_resolution_clock::duration)>
decodingTimeCallback;
};

class VeloxReader {
Expand Down

0 comments on commit bb0fa53

Please sign in to comment.