dht: fragment token_range_vector
token_range_vector is a linear vector containing intervals of tokens. It can grow quite large in certain places and so cause stalls. Convert it to utils::chunked_vector, which prevents allocation stalls. It is not used in any hot path, as it usually describes vnodes or similar things. Fixes #3335.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "interval.hh"
|
||||
#include "utils/chunked_vector.hh"
|
||||
|
||||
namespace sstables {
|
||||
|
||||
@@ -29,7 +30,7 @@ using partition_range = interval<ring_position>;
|
||||
using token_range = interval<token>;
|
||||
|
||||
using partition_range_vector = std::vector<partition_range>;
|
||||
using token_range_vector = std::vector<token_range>;
|
||||
using token_range_vector = utils::chunked_vector<token_range>;
|
||||
|
||||
class decorated_key;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class stream_request {
|
||||
sstring keyspace;
|
||||
// For compatibility with <= 1.5, we use wrapping ranges
|
||||
// (though we never send wraparounds; only allow receiving them)
|
||||
std::vector<wrapping_interval<dht::token>> ranges_compat();
|
||||
utils::chunked_vector<wrapping_interval<dht::token>> ranges_compat();
|
||||
std::vector<sstring> column_families;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "gms/gossip_address_map.hh"
|
||||
#include "tasks/types.hh"
|
||||
#include "utils/advanced_rpc_compressor.hh"
|
||||
#include "utils/chunked_vector.hh"
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
@@ -64,7 +65,7 @@ namespace dht {
|
||||
class ring_position;
|
||||
using partition_range = interval<ring_position>;
|
||||
using token_range = interval<token>;
|
||||
using token_range_vector = std::vector<token_range>;
|
||||
using token_range_vector = utils::chunked_vector<token_range>;
|
||||
}
|
||||
|
||||
namespace query {
|
||||
|
||||
@@ -110,13 +110,13 @@ wrap(Container<interval<T>>&& v) {
|
||||
|
||||
inline
|
||||
dht::token_range_vector
|
||||
unwrap(const std::vector<wrapping_interval<dht::token>>& v) {
|
||||
unwrap(const utils::chunked_vector<wrapping_interval<dht::token>>& v) {
|
||||
return unwrap(v, dht::token_comparator());
|
||||
}
|
||||
|
||||
inline
|
||||
dht::token_range_vector
|
||||
unwrap(std::vector<wrapping_interval<dht::token>>&& v) {
|
||||
unwrap(utils::chunked_vector<wrapping_interval<dht::token>>&& v) {
|
||||
return unwrap(std::move(v), dht::token_comparator());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
sstring keyspace;
|
||||
dht::token_range_vector ranges;
|
||||
// For compatibility with <= 1.5, we send wrapping ranges (though they will never wrap).
|
||||
std::vector<wrapping_interval<token>> ranges_compat() const {
|
||||
utils::chunked_vector<wrapping_interval<token>> ranges_compat() const {
|
||||
return ::compat::wrap(ranges);
|
||||
}
|
||||
std::vector<sstring> column_families;
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
, ranges(std::move(_ranges))
|
||||
, column_families(std::move(_column_families)) {
|
||||
}
|
||||
stream_request(sstring _keyspace, std::vector<wrapping_interval<token>> _ranges, std::vector<sstring> _column_families)
|
||||
stream_request(sstring _keyspace, utils::chunked_vector<wrapping_interval<token>> _ranges, std::vector<sstring> _column_families)
|
||||
: stream_request(std::move(_keyspace), ::compat::unwrap(std::move(_ranges)), std::move(_column_families)) {
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user