mirror of
https://github.com/ceph/ceph
synced 2025-01-29 22:43:40 +00:00
mempool: make num_shards a power of 2
Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
735be3662f
commit
b174694493
@ -213,7 +213,12 @@ struct list_member_t {
|
||||
|
||||
// we shard pool stats across many shard_t's to reduce the amount
|
||||
// of cacheline ping pong.
|
||||
enum { num_shards = 64 };
|
||||
enum {
|
||||
num_shard_bits = 5
|
||||
};
|
||||
enum {
|
||||
num_shards = 1 << num_shard_bits
|
||||
};
|
||||
|
||||
struct shard_t {
|
||||
std::atomic<size_t> bytes = {0};
|
||||
@ -277,7 +282,7 @@ public:
|
||||
// Dirt cheap, see:
|
||||
// http://fossies.org/dox/glibc-2.24/pthread__self_8c_source.html
|
||||
size_t me = (size_t)pthread_self();
|
||||
size_t i = (me >> 3) % num_shards;
|
||||
size_t i = (me >> 3) & ((1 << num_shard_bits) - 1);
|
||||
return &shard[i];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user