mv: adjust memory tracking of single view updates within a batch
Currently, when dividing memory tracked for a batch of updates we do not take into account the overhead that we have for processing every update. This patch adds the overhead for single updates and joins the memory calculation path for batches and their parts so that both use the same overhead. Fixes #17854 Closes scylladb/scylladb#17855
This commit is contained in:
committed by
Nadav Har'El
parent
2c9b13d2d1
commit
efcb718e0a
@@ -1685,6 +1685,13 @@ static bool should_update_synchronously(const schema& s) {
|
||||
return *tag_opt == "true";
|
||||
}
|
||||
|
||||
size_t memory_usage_of(const frozen_mutation_and_schema& mut) {
|
||||
// Overhead of sending a view mutation, in terms of data structures used by the storage_proxy, as well as possible background tasks
|
||||
// allocated for a remote view update.
|
||||
constexpr size_t base_overhead_bytes = 2288;
|
||||
return base_overhead_bytes + mut.fm.representation().size();
|
||||
}
|
||||
|
||||
// Take the view mutations generated by generate_view_updates(), which pertain
|
||||
// to a modification of a single base partition, and apply them to the
|
||||
// appropriate paired replicas. This is done asynchronously - we do not wait
|
||||
@@ -1716,7 +1723,7 @@ future<> view_update_generator::mutate_MV(
|
||||
bool use_legacy_self_pairing = !ks.uses_tablets();
|
||||
auto target_endpoint = get_view_natural_endpoint(base_ermp, view_ermp, network_topology, base_token, view_token, use_legacy_self_pairing);
|
||||
auto remote_endpoints = view_ermp->get_pending_endpoints(view_token);
|
||||
auto sem_units = pending_view_updates.split(mut.fm.representation().size());
|
||||
auto sem_units = pending_view_updates.split(memory_usage_of(mut));
|
||||
|
||||
const bool update_synchronously = should_update_synchronously(*mut.s);
|
||||
if (update_synchronously) {
|
||||
|
||||
@@ -315,6 +315,8 @@ future<query::clustering_row_ranges> calculate_affected_clustering_ranges(
|
||||
|
||||
bool needs_static_row(const mutation_partition& mp, const std::vector<view_and_base>& views);
|
||||
|
||||
size_t memory_usage_of(const frozen_mutation_and_schema& mut);
|
||||
|
||||
/**
|
||||
* create_virtual_column() adds a "virtual column" to a schema builder.
|
||||
* The definition of a "virtual column" is based on the given definition
|
||||
|
||||
@@ -2598,12 +2598,9 @@ std::vector<view_ptr> table::affected_views(shared_ptr<db::view::view_update_gen
|
||||
}
|
||||
|
||||
static size_t memory_usage_of(const utils::chunked_vector<frozen_mutation_and_schema>& ms) {
|
||||
// Overhead of sending a view mutation, in terms of data structures used by the storage_proxy, as well as possible background tasks
|
||||
// allocated for a remote view update.
|
||||
constexpr size_t base_overhead_bytes = 2288;
|
||||
return boost::accumulate(ms | boost::adaptors::transformed([] (const frozen_mutation_and_schema& m) {
|
||||
return m.fm.representation().size();
|
||||
}), size_t{base_overhead_bytes * ms.size()});
|
||||
return db::view::memory_usage_of(m);
|
||||
}), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user