From 9baf1226dcd48a2abc36eaefbaa58ae39dd94e49 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Mon, 15 Feb 2021 18:27:11 +0300 Subject: [PATCH] test/memory_footpring: Print radix tree node sizes After switching cells storage onto compact radix tree it becomes useful to know the tree nodes' sizes. Signed-off-by: Pavel Emelyanov --- mutation_partition.hh | 1 + test/perf/memory_footprint_test.cc | 15 +++++++++++++++ utils/compact-radix-tree.hh | 3 +++ 3 files changed, 19 insertions(+) diff --git a/mutation_partition.hh b/mutation_partition.hh index 88084b68e7..f6dabc93c2 100644 --- a/mutation_partition.hh +++ b/mutation_partition.hh @@ -97,6 +97,7 @@ class compaction_garbage_collector; // // class row { + friend class size_calculator; using size_type = std::make_unsigned_t; size_type _size = 0; using sparse_array_type = compact_radix_tree::tree; diff --git a/test/perf/memory_footprint_test.cc b/test/perf/memory_footprint_test.cc index dd9261e614..be660ec839 100644 --- a/test/perf/memory_footprint_test.cc +++ b/test/perf/memory_footprint_test.cc @@ -40,6 +40,8 @@ #include "test/lib/reader_permit.hh" class size_calculator { + using cells_type = row::sparse_array_type; + class nest { public: static thread_local int level; @@ -73,6 +75,19 @@ public: std::cout << prefix() << "sizeof(lru_link_type) = " << sizeof(rows_entry::lru_link_type) << "\n"; std::cout << prefix() << "sizeof(deletable_row) = " << sizeof(deletable_row) << "\n"; std::cout << prefix() << "sizeof(row) = " << sizeof(row) << "\n"; + std::cout << prefix() << "radix_tree::inner_node::node_sizes = "; + for (int i = 4; i <= 128; i *= 2) { + std::cout << " " << cells_type::inner_node::node_type::node_size(cells_type::layout::direct_dynamic, i); + } + std::cout << "\n"; + std::cout << prefix() << "radix_tree::leaf_node::node_sizes = "; + std::cout << " " << cells_type::leaf_node::node_type::node_size(cells_type::layout::indirect_tiny, 0); + std::cout << " " << cells_type::leaf_node::node_type::node_size(cells_type::layout::indirect_small, 0); + std::cout << " " << cells_type::leaf_node::node_type::node_size(cells_type::layout::indirect_medium, 0); + std::cout << " " << cells_type::leaf_node::node_type::node_size(cells_type::layout::indirect_large, 0); + std::cout << " " << cells_type::leaf_node::node_type::node_size(cells_type::layout::direct_static, 0); + std::cout << "\n"; + std::cout << prefix() << "sizeof(atomic_cell_or_collection) = " << sizeof(atomic_cell_or_collection) << "\n"; std::cout << prefix() << "btree::linear_node_size(1) = " << mutation_partition::rows_type::node::linear_node_size(1) << "\n"; std::cout << prefix() << "btree::inner_node_size = " << mutation_partition::rows_type::node::inner_node_size << "\n"; diff --git a/utils/compact-radix-tree.hh b/utils/compact-radix-tree.hh index a9398afbba..adff5560aa 100644 --- a/utils/compact-radix-tree.hh +++ b/utils/compact-radix-tree.hh @@ -28,6 +28,8 @@ #include "utils/allocation_strategy.hh" #include "utils/array-search.hh" +class size_calculator; + namespace compact_radix_tree { template class printer; @@ -105,6 +107,7 @@ struct variadic_union { template requires std::is_nothrow_move_constructible_v && std::is_integral_v class tree { + friend class ::size_calculator; template friend class printer; class leaf_node;