Skip to content

Commit

Permalink
Record pause time per task
Browse files Browse the repository at this point in the history
Differential Revision: D55159826
  • Loading branch information
Yuhta authored and facebook-github-bot committed Mar 21, 2024
1 parent 86f12b7 commit 8063f23
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions velox/exec/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ struct ThreadState {
/// driver goes off thread. This is used to track the time that a driver has
/// continuously run on a thread for per-driver cpu time slice enforcement.
size_t startExecTimeMs{0};
/// The end execution time on thread in milliseconds. It is set when the
/// driver goes off thread and reset when the driver gets on a thread.
size_t endExecTimeMs{0};

bool isOnThread() const {
return thread != std::thread::id();
Expand All @@ -118,6 +121,7 @@ struct ThreadState {
void setThread() {
thread = std::this_thread::get_id();
startExecTimeMs = getCurrentTimeMs();
endExecTimeMs = 0;
#if !defined(__APPLE__)
// This is a debugging feature disabled on the Mac since syscall
// is deprecated on that platform.
Expand All @@ -128,6 +132,7 @@ struct ThreadState {
void clearThread() {
thread = std::thread::id(); // no thread.
startExecTimeMs = 0;
endExecTimeMs = getCurrentTimeMs();
tid = 0;
}

Expand Down
2 changes: 2 additions & 0 deletions velox/exec/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,8 @@ void Task::resume(std::shared_ptr<Task> self) {
if (!driver->state().hasBlockingFuture) {
// Do not continue a Driver that is blocked on external
// event. The Driver gets enqueued by the promise realization.
self->taskStats_.totalPauseTimeMs +=
getCurrentTimeMs() - driver->state().endExecTimeMs;
Driver::enqueue(driver);
}
}
Expand Down
3 changes: 3 additions & 0 deletions velox/exec/TaskStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ struct TaskStats {
/// Drivers blocked for various reasons. Based on enum BlockingReason.
std::unordered_map<BlockingReason, uint64_t> numBlockedDrivers;

/// Total pause time (ms) for all drivers.
uint64_t totalPauseTimeMs{0};

/// Output buffer's memory utilization ratio measured as
/// current buffer usage / max buffer size
double outputBufferUtilization{0};
Expand Down

0 comments on commit 8063f23

Please sign in to comment.