From 919efabe4b64bfc76fdffb47c99cc496781a5bb6 Mon Sep 17 00:00:00 2001 From: Zhang Lei Date: Thu, 24 Oct 2024 14:03:22 +0800 Subject: [PATCH] feat(interactive): Increase the reserved slots for small graphs (#4299) We currently allocate an additional 1/4 of the required space when opening a graph, resulting in a smaller reserved space for smaller graphs. To address this, we are increasing the minimum capacity for vertex storage to 4096. Fix #4105 --- .../storages/rt_mutable_graph/mutable_property_fragment.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc index 4fc437820046..1cb2c329efd5 100644 --- a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc +++ b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc @@ -191,12 +191,11 @@ void MutablePropertyFragment::Open(const std::string& work_dir, schema_.get_vertex_storage_strategies(v_label_name), true); } + // We will reserve the at least 4096 slots for each vertex label size_t vertex_capacity = - schema_.get_max_vnum(v_label_name); // lf_indexers_[i].capacity(); - if (build_empty_graph) { + std::max(lf_indexers_[i].capacity(), (size_t) 4096); + if (vertex_capacity >= lf_indexers_[i].size()) { lf_indexers_[i].reserve(vertex_capacity); - } else { - vertex_capacity = lf_indexers_[i].capacity(); } vertex_data_[i].resize(vertex_capacity); vertex_capacities[i] = vertex_capacity;