You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2018/09/20 21:42:54 UTC
[mesos] 02/02: Reserve sort output vector in the sorters.
This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 8df68cc543911b634da6064fa76da270c72f6eb1
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Sun Sep 16 16:36:10 2018 -0700
Reserve sort output vector in the sorters.
This reserves the sort output vector consistently based on
the number of clients, in both the DRF and random sorters.
Review: https://reviews.apache.org/r/68730
---
src/master/allocator/sorter/drf/sorter.cpp | 4 ++++
src/master/allocator/sorter/random/sorter.cpp | 3 +++
2 files changed, 7 insertions(+)
diff --git a/src/master/allocator/sorter/drf/sorter.cpp b/src/master/allocator/sorter/drf/sorter.cpp
index aa925c4..a45f66f 100644
--- a/src/master/allocator/sorter/drf/sorter.cpp
+++ b/src/master/allocator/sorter/drf/sorter.cpp
@@ -551,6 +551,10 @@ vector<string> DRFSorter::sort()
// inactive leaves sorted after active leaves and internal nodes.
vector<string> result;
+ // TODO(bmahler): This over-reserves where there are inactive
+ // clients, only reserve the number of active clients.
+ result.reserve(clients.size());
+
std::function<void (const Node*)> listClients =
[&listClients, &result](const Node* node) {
foreach (const Node* child, node->children) {
diff --git a/src/master/allocator/sorter/random/sorter.cpp b/src/master/allocator/sorter/random/sorter.cpp
index 7b98389..fc47756 100644
--- a/src/master/allocator/sorter/random/sorter.cpp
+++ b/src/master/allocator/sorter/random/sorter.cpp
@@ -497,6 +497,9 @@ vector<string> RandomSorter::sort()
// The children of each node are already shuffled, with
// inactive leaves stored after active leaves and internal nodes.
vector<string> result;
+
+ // TODO(bmahler): This over-reserves where there are inactive
+ // clients, only reserve the number of active clients.
result.reserve(clients.size());
std::function<void (const Node*)> listClients =