-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add arbitration participant and operation objects to support global memory arbitration optimization #11074
Conversation
✅ Deploy Preview for meta-velox canceled.
|
This pull request was exported from Phabricator. Differential Revision: D63055730 |
uint64_t fastExponentialGrowthCapacityLimit; | ||
double slowCapacityGrowRatio; | ||
|
||
/// When shrinking a memory pool capacity, the shrink bytes will be adjusted | ||
/// in a way such that AFTER shrink, the stricter (whichever is smaller) of | ||
/// the following conditions is met, in order to better fit the query memory | ||
/// pool's current memory usage: | ||
/// - Free capacity is greater or equal to capacity * | ||
/// 'minFreeCapacityRatio' | ||
/// - Free capacity is greater or equal to 'minFreeCapacity' | ||
/// | ||
/// NOTE: in the conditions when original requested shrink bytes ends up | ||
/// with more free capacity than above 2 conditions, the adjusted shrink | ||
/// bytes is not respected. | ||
/// | ||
/// NOTE: capacity shrink adjustment is enabled when both | ||
/// 'minFreeCapacityRatio' and 'minFreeCapacity' are set. | ||
uint64_t minFreeCapacity; | ||
double minFreeCapacityRatio; |
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.
Shall we make the names consistent with other code locations? Here are the names in SharedArbitrator
const uint64_t fastExponentialGrowthCapacityLimit_;
const double slowCapacityGrowPct_;
const uint64_t memoryPoolMinFreeCapacity_;
const double memoryPoolMinFreeCapacityPct_;
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.
This are the configs defined in ArbitrationParticipant for memory pool so we don't need memory pool prefix, and we shall change slowCapacityGrowPct_ to slowCapacityGrowRatio_
/// capacity growth target is set to have a coarser granularity. It can help | ||
/// to reduce the number of future grow calls, and hence reducing the number | ||
/// of unnecessary memory arbitration requests. | ||
void getGrowTargets( |
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.
Since we are doing the refactoring, could you also help to add documentations on the 2 return values? max and min grow bytes. Thanks
ArbitrationParticipant::Config::Config( | ||
uint64_t _minCapacity, | ||
uint64_t _fastExponentialGrowthCapacityLimit, | ||
double _slowCapacityGrowRatio, |
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.
ditto, shall we align these names?
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.
Replied
} | ||
|
||
uint64_t ArbitrationParticipant::maxShrinkCapacity() const { | ||
const uint64_t capacity = pool_->capacity(); |
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.
this local v is only used once
/// for the prior arbitration operations to finish first before executing to | ||
/// ensure the serialized execution of arbitration operations from the same | ||
/// query memory pool. | ||
void startArbitration(ArbitrationOperation* op); |
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.
Shall we rename this method to enqueueArbitration() as technically the arbitration is not started by this method?
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.
When the function returns, the operation is started so I think it is better to call this startArbitration.
/// latter ensures the serialized execution of arbitration operations from the | ||
/// same query with one at a time. So this method blocks until all the prior | ||
/// arbitration operations finish. | ||
void start(); |
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.
similarly, start() method does not technically start the arbitration. Shall we rename it?
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.
Replied
uint64_t maxGrowBytes() const { | ||
return maxGrowBytes_; | ||
} | ||
|
||
/// Returns the min grow bytes for this arbitration operation to ensure the | ||
/// arbitration participant has the minimum amount of memory capacity. The | ||
/// arbitrator might allocate memory from the reserved memory capacity pool | ||
/// for the min grow bytes. | ||
uint64_t minGrowBytes() const { | ||
return minGrowBytes_; |
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.
These 2 methods going to be used in the followup PRs?
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.
yes
|
||
/// Returns the allocated bytes by this arbitration operation. | ||
uint64_t& allocatedBytes() { | ||
return allocatedBytes_; |
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.
just make it public or protected if needed to be accessed like this?
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.
Yes, in followup.
…emory arbitration optimization (facebookincubator#11074) Summary: Pull Request resolved: facebookincubator#11074 Add arbitration participant object to provide all the required arbitration operations and state management on a query memory pool inside the memory arbitrator, such as arbitration queue to serialize the arbitration request execution from the same query and the serialize the reclaim, shrink, grow and abort from either arbitration request and the background memory arbitrations. Add arbitration operation object to manage a memory arbitration request execution Reviewed By: tanjialiang Differential Revision: D63055730
b4a8713
to
8157161
Compare
This pull request was exported from Phabricator. Differential Revision: D63055730 |
1 similar comment
This pull request was exported from Phabricator. Differential Revision: D63055730 |
…emory arbitration optimization (facebookincubator#11074) Summary: Pull Request resolved: facebookincubator#11074 Add arbitration participant object to provide all the required arbitration operations and state management on a query memory pool inside the memory arbitrator, such as arbitration queue to serialize the arbitration request execution from the same query and the serialize the reclaim, shrink, grow and abort from either arbitration request and the background memory arbitrations. Add arbitration operation object to manage a memory arbitration request execution Reviewed By: tanjialiang Differential Revision: D63055730
8157161
to
1f07150
Compare
This pull request was exported from Phabricator. Differential Revision: D63055730 |
…emory arbitration optimization (facebookincubator#11074) Summary: Pull Request resolved: facebookincubator#11074 Add arbitration participant object to provide all the required arbitration operations and state management on a query memory pool inside the memory arbitrator, such as arbitration queue to serialize the arbitration request execution from the same query and the serialize the reclaim, shrink, grow and abort from either arbitration request and the background memory arbitrations. Add arbitration operation object to manage a memory arbitration request execution Reviewed By: tanjialiang Differential Revision: D63055730
1f07150
to
6bf4d98
Compare
…emory arbitration optimization (facebookincubator#11074) Summary: Pull Request resolved: facebookincubator#11074 Add arbitration participant object to provide all the required arbitration operations and state management on a query memory pool inside the memory arbitrator, such as arbitration queue to serialize the arbitration request execution from the same query and the serialize the reclaim, shrink, grow and abort from either arbitration request and the background memory arbitrations. Add arbitration operation object to manage a memory arbitration request execution Reviewed By: tanjialiang Differential Revision: D63055730
This pull request was exported from Phabricator. Differential Revision: D63055730 |
6bf4d98
to
cd51932
Compare
This pull request has been merged in dcaae29. |
Conbench analyzed the 1 benchmark run on commit There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
Summary:
Add arbitration participant object to provide all the required arbitration operations and state management on a
query memory pool inside the memory arbitrator, such as arbitration queue to serialize the arbitration request execution
from the same query and the serialize the reclaim, shrink, grow and abort from either arbitration request and the
background memory arbitrations.
Add arbitration operation object to manage a memory arbitration request execution
Differential Revision: D63055730