Skip to content

Commit

Permalink
Fix OutputBuffer::isOverutilized (facebookincubator#7985)
Browse files Browse the repository at this point in the history
Summary:
OutputBuffer::isOverutilized() should return true if it is half-full. It used to
return true only when full preventing effective scaling of consumers. The
buffer maintains is-full state only for a short duration of time. Since
producers are blocked, one fetch from one consumer resets the state to
not-null. Thus the coordinator that's monitoring output buffers may never see
buffer getting over-utilized and mitigate by scaling the number of consumers.
This caused some queries to be very slow as they used only 4 threads for
TableWrite.

Pull Request resolved: facebookincubator#7985

Reviewed By: Yuhta

Differential Revision: D52073744

Pulled By: mbasmanova

fbshipit-source-id: 246e065d885ce52601acd4cdcba5e708c5628da5
  • Loading branch information
mbasmanova authored and facebook-github-bot committed Dec 12, 2023
1 parent 5342711 commit 6122630
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion velox/exec/OutputBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ double OutputBuffer::getUtilization() const {
}

bool OutputBuffer::isOverutilized() const {
return (totalSize_ > maxSize_) && !atEnd_;
return (totalSize_ > (0.5 * maxSize_)) && !atEnd_;
}

} // namespace facebook::velox::exec
5 changes: 3 additions & 2 deletions velox/exec/OutputBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ class OutputBuffer {
// Gets the memory utilization ratio in this output buffer.
double getUtilization() const;

// Indicates if this output buffer is over-utilized and thus blocks its
// producers.
// Indicates if this output buffer is over-utilized, i.e. at least half full,
// and will start blocking producers soon. This is used to dynamically scale
// the number of consumers, for example, increase number of TableWriter tasks.
bool isOverutilized() const;

private:
Expand Down

0 comments on commit 6122630

Please sign in to comment.