#include "memory/concurrent_arena.h"
#include <thread>
#include "port/port.h"
#include "util/random.h"
namespace ROCKSDB_NAMESPACE {
thread_local size_t ConcurrentArena::tls_cpuid = 0;
namespace {
const size_t kMaxShardBlockSize = size_t{128 * 1024};
}
ConcurrentArena::ConcurrentArena(size_t block_size, AllocTracker* tracker,
size_t huge_page_size)
: shard_block_size_(std::min(kMaxShardBlockSize, block_size / 8)),
shards_(),
arena_(block_size, tracker, huge_page_size) {
Fixup();
}
ConcurrentArena::Shard* ConcurrentArena::Repick() {
auto shard_and_index = shards_.AccessElementAndIndex();
tls_cpuid = shard_and_index.second | shards_.Size();
return shard_and_index.first;
}
}