You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/04/25 23:32:07 UTC
[14/50] mesos git commit: Allocator Performance: Simplified Sorter's
'CalculateShare'.
Allocator Performance: Simplified Sorter's 'CalculateShare'.
Used existing functions to aggregate Scalars in the 'Resources' object.
Review: https://reviews.apache.org/r/42890/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e62817dc
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e62817dc
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e62817dc
Branch: refs/heads/0.26.x
Commit: e62817dc0df85d467ce621ab224ad1d8926ac11c
Parents: 6c63f02
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Wed Jan 27 19:14:21 2016 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Fri Feb 26 20:59:05 2016 -0800
----------------------------------------------------------------------
src/master/allocator/sorter/drf/sorter.cpp | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e62817dc/src/master/allocator/sorter/drf/sorter.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/sorter.cpp b/src/master/allocator/sorter/drf/sorter.cpp
index 33c47e7..94690aa 100644
--- a/src/master/allocator/sorter/drf/sorter.cpp
+++ b/src/master/allocator/sorter/drf/sorter.cpp
@@ -328,24 +328,28 @@ double DRFSorter::calculateShare(const string& name)
// scalars.
foreach (const string& scalar, total.scalars.names()) {
- double _total = 0.0;
-
+ // We collect the scalar accumulated total value from the
+ // `Resources` object.
+ //
// NOTE: Scalar resources may be spread across multiple
// 'Resource' objects. E.g. persistent volumes.
- foreach (const Resource& resource, total.scalars.get(scalar)) {
- CHECK_EQ(resource.type(), Value::SCALAR);
- _total += resource.scalar().value();
- }
+ Option<Value::Scalar> __total = total.scalars.get<Value::Scalar>(scalar);
+ CHECK_SOME(__total);
+ const double _total = __total.get().value();
if (_total > 0.0) {
double allocation = 0.0;
+ // We collect the scalar accumulated allocation value from the
+ // `Resources` object.
+ //
// NOTE: Scalar resources may be spread across multiple
// 'Resource' objects. E.g. persistent volumes.
- foreach (const Resource& resource,
- allocations[name].scalars.get(scalar)) {
- CHECK_EQ(resource.type(), Value::SCALAR);
- allocation += resource.scalar().value();
+ Option<Value::Scalar> _allocation =
+ allocations[name].scalars.get<Value::Scalar>(scalar);
+
+ if (_allocation.isSome()) {
+ allocation = _allocation.get().value();
}
share = std::max(share, allocation / _total);