utils/large_bitset: use reserve_partial() to reserve _storage

To avoid stalls when reserving memory for a large bloom filter. The
filter creation already has a yielding loop for initialization, this
patch extends it to reservation of memory too.
This commit is contained in:
Botond Dénes
2020-11-02 15:45:45 +02:00
parent bb908b1750
commit a08b640fa7

View File

@@ -30,8 +30,15 @@ using namespace seastar;
large_bitset::large_bitset(size_t nr_bits) : _nr_bits(nr_bits) {
assert(thread::running_in_thread());
size_t nr_ints = align_up(nr_bits, bits_per_int()) / bits_per_int();
_storage.reserve(nr_ints);
const size_t orig_nr_ints = align_up(nr_bits, bits_per_int()) / bits_per_int();
auto nr_ints = orig_nr_ints;
while (nr_ints) {
nr_ints = _storage.reserve_partial(nr_ints);
if (need_preempt()) {
thread::yield();
}
}
nr_ints = orig_nr_ints;
while (nr_ints) {
_storage.push_back(0);
--nr_ints;