This change includes basic optimizations to locator::describe_ring, mainly caching the per-endpoint information in an unordered_map instead of looking them up in every inner-loop. This yields an improvement of 20% in cpu time. With 45 nodes organized as 3 dcs, 3 racks per dc, 5 nodes per rack, 256 tokens per node, yielding 11520 ranges and 9 replicas per range, describe_ring took Before: 30 milliseconds (2.6 microseconds per range) After: 24 milliseconds (2.1 microseconds per range) Add respective unit test of describe_ring for tablets. A unit test for vnodes already exists in test/nodetool/test_describering.py Fixes #24887 Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
/*
|
|
* Copyright (C) 2022-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "dht/token_range_endpoints.hh"
|
|
#include "dht/i_partitioner_fwd.hh"
|
|
#include "inet_address_vectors.hh"
|
|
#include "locator/abstract_replication_strategy.hh"
|
|
#include "utils/chunked_vector.hh"
|
|
|
|
namespace replica {
|
|
class database;
|
|
}
|
|
|
|
namespace gms {
|
|
class gossiper;
|
|
}
|
|
|
|
namespace locator {
|
|
future<utils::chunked_vector<dht::token_range_endpoints>> describe_ring(const replica::database& db, const gms::gossiper& gossiper, const sstring& keyspace, bool include_only_local_dc = false);
|
|
future<std::unordered_map<dht::token_range, host_id_vector_replica_set>> get_range_to_address_map(
|
|
locator::effective_replication_map_ptr erm, const utils::chunked_vector<token>& sorted_tokens);
|
|
|
|
struct describe_ring_endpoint_info {
|
|
dht::endpoint_details details;
|
|
sstring rpc_addr;
|
|
};
|
|
describe_ring_endpoint_info get_describe_ring_endpoint_info(host_id endpoint, const topology& topology, const gms::gossiper& gossiper);
|
|
}
|