Repository navigation
luminous: BlueStore.cc: _balance_bluefs_freespace: assert(0 == "allocate failed, wtf"); - #21394
Merged
Merged
Conversation
Iterate over all elements of the smaller set, and use find_inc to
locate elements from the larger set in logarithmic time. This greatly
improves performance when one set is much larger than the other:
2 +-+--+----+----+----+----+----+----+----+----+--+-+
P +* +
E |* |
R 1.8 +* +
F | * |
O | * |
R 1.6 + * +
M | * |
A | * |
N 1.4 + * +
C | * |
E | * |
1.2 + * +
R | * |
A | * |
T 1 + *** +
I | ****** |
O + ***********************************
0.8 +-+--+----+----+----+----+----+----+----+----+--+-+
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
SET SIZE RATIO
The above plot compares performance of the new intersection_size_asym
function to the existing intersection_of function. The performance of
intersection_size_asym gets worse as the set size ratio approaches 1.
For set size ratios where the performance ratio is greater than 1, the
performance of intersection_size_asym is superior. Therefore, this
patch only uses intersection_size_asym when the set size ratio is less
than or equal to 0.1 (code uses the reciprocal which is 10).
The plot was generated using benchmark results produced by the
following program:
#include <iostream>
#include <sys/timeb.h>
#include "include/interval_set.h"
int main()
{
const int interval_count = 100000;
const int interval_distance = 4;
const int interval_size = 2;
const int sample_count = 8;
const int max_offset = interval_count * interval_distance;
interval_set<int> a, b, intersection;
for (int i = 0; i < max_offset; i+=interval_distance) {
a.insert(i, interval_size);
}
for (int m = 1; m < 100; m++) {
float ratio = 1 / float(m);
for (int i = 0; i < max_offset; i+=interval_distance*m) {
b.insert(i, interval_size);
}
struct timeb start, end;
int ms = 0;
for (int i = 0; i < sample_count; i++) {
ftime(&start);
intersection.intersection_of(a, b);
ftime(&end);
ms += (int) (1000.0 * (end.time - start.time)
+ (end.millitm - start.millitm));
intersection.clear();
}
b.clear();
std::cout << ratio << "\t" << ms << std::endl << std::flush;
}
}
Signed-off-by: Zac Medico <[email protected]>
(cherry picked from commit 825470f)
Optimize subset_of to use sequential search when it performs better than the lower_bound method, for set size ratios smaller than 10. This is analogous to intersection_of behavior since commit 825470f. The subset_of method can be used in some cases as a less-expensive alternative to the intersection_of method, since subset_of can return early if any element of the smaller set is not contained in the larger set, and intersection_of has the added burden of storing the intersecting elements. Signed-off-by: Zac Medico <[email protected]> (cherry picked from commit 5c37758)
E.g.: subset_of([5~10,20~5], 0, 100) -> [5~10,20~5] subset_of([5~10,20~5], 5, 25) -> [5~10,20~5] subset_of([5~10,20~5], 1, 10) -> [5~5] subset_of([5~10,20~5], 8, 24) -> [8~7, 20~4] Signed-off-by: xie xingguo <[email protected]> (cherry picked from commit f90bd4b)
Default to std::map for backward compat. Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit d254259)
These changes picked out of the diff between the original btree_interval_set.h and interval_set.h (sadly I had it rolled into the initial commit so it was tedious to identify these). Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit 87aed20)
Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit 79f9c86)
Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit 78d5afd)
This avoid the code duplication, yay! Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit 762dd42)
Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit 3dafe9d)
c{begin,end} don't exist for btree_map<>.
Signed-off-by: Sage Weil <[email protected]>
(cherry picked from commit 7bbb795)
Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit 70ddb0c)
…_free Signed-off-by: Igor Fedotov <[email protected]> (cherry picked from commit 89aeea8)
Signed-off-by: Igor Fedotov <[email protected]> (cherry picked from commit eb0443a)
rebalance Signed-off-by: Igor Fedotov <[email protected]> (cherry picked from commit 64abc7b)
liewegas
approved these changes
Apr 12, 2018
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pulls more commits than the original PR since it relies on multiple changes around interval_set.
http://tracker.ceph.com/issues/23063