From 8fe4fd1dac3c12dda6ed78fd44c83706bcf5ddfa Mon Sep 17 00:00:00 2001 From: "xiaolei.zl" Date: Thu, 24 Oct 2024 11:41:17 +0800 Subject: [PATCH 1/5] increase the reserved slots for small graphs Committed-by: xiaolei.zl from Dev container --- .../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..53c14cf6ea49 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(schema_.get_max_vnum(v_label_name), (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; From 20bd8d6a6b16b225446409ff637acd35b2381524 Mon Sep 17 00:00:00 2001 From: "xiaolei.zl" Date: Thu, 24 Oct 2024 12:17:04 +0800 Subject: [PATCH 2/5] fix Committed-by: xiaolei.zl from Dev container --- flex/storages/rt_mutable_graph/mutable_property_fragment.cc | 5 ++++- flex/storages/rt_mutable_graph/schema.h | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc index 53c14cf6ea49..b00837dcf0c0 100644 --- a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc +++ b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc @@ -192,8 +192,11 @@ void MutablePropertyFragment::Open(const std::string& work_dir, } // We will reserve the at least 4096 slots for each vertex label + auto max_vnum = schema_.get_max_vnum(v_label_name); size_t vertex_capacity = - std::max(schema_.get_max_vnum(v_label_name), (size_t) 4096); + std::max(max_vnum == Schema::DEFAULT_MAX_VNUM ? lf_indexers_[i].size() + : max_vnum, + (size_t) 4096); if (vertex_capacity >= lf_indexers_[i].size()) { lf_indexers_[i].reserve(vertex_capacity); } diff --git a/flex/storages/rt_mutable_graph/schema.h b/flex/storages/rt_mutable_graph/schema.h index 1f696aabd921..7a48fe3f88bd 100644 --- a/flex/storages/rt_mutable_graph/schema.h +++ b/flex/storages/rt_mutable_graph/schema.h @@ -67,6 +67,7 @@ class Schema { // An array containing all compatible versions of schema. static const std::vector COMPATIBLE_VERSIONS; static constexpr const char* DEFAULT_SCHEMA_VERSION = "v0.0"; + static constexpr const size_t DEFAULT_MAX_VNUM = (1ULL << 32); static bool IsBuiltinPlugin(const std::string& plugin_name); @@ -84,8 +85,7 @@ class Schema { const std::vector>& primary_key, const std::vector& strategies = {}, - size_t max_vnum = static_cast(1) << 32, - const std::string& description = ""); + size_t max_vnum = DEFAULT_MAX_VNUM, const std::string& description = ""); void add_edge_label(const std::string& src_label, const std::string& dst_label, From 99c769bd77a00bd95ed51893184ac85fa922b4c0 Mon Sep 17 00:00:00 2001 From: "xiaolei.zl" Date: Thu, 24 Oct 2024 12:52:47 +0800 Subject: [PATCH 3/5] fix Committed-by: xiaolei.zl from Dev container --- flex/storages/rt_mutable_graph/mutable_property_fragment.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc index b00837dcf0c0..c912fa5c3c2f 100644 --- a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc +++ b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc @@ -192,11 +192,7 @@ void MutablePropertyFragment::Open(const std::string& work_dir, } // We will reserve the at least 4096 slots for each vertex label - auto max_vnum = schema_.get_max_vnum(v_label_name); - size_t vertex_capacity = - std::max(max_vnum == Schema::DEFAULT_MAX_VNUM ? lf_indexers_[i].size() - : max_vnum, - (size_t) 4096); + size_t vertex_capacity = std::max(lf_indexers_[i].size(), (size_t) 4096); if (vertex_capacity >= lf_indexers_[i].size()) { lf_indexers_[i].reserve(vertex_capacity); } From b10cc71a25a435ff9738b42ceff8d80df0dd5205 Mon Sep 17 00:00:00 2001 From: "xiaolei.zl" Date: Thu, 24 Oct 2024 12:54:22 +0800 Subject: [PATCH 4/5] minor Committed-by: xiaolei.zl from Dev container --- flex/storages/rt_mutable_graph/schema.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flex/storages/rt_mutable_graph/schema.h b/flex/storages/rt_mutable_graph/schema.h index 7a48fe3f88bd..1f696aabd921 100644 --- a/flex/storages/rt_mutable_graph/schema.h +++ b/flex/storages/rt_mutable_graph/schema.h @@ -67,7 +67,6 @@ class Schema { // An array containing all compatible versions of schema. static const std::vector COMPATIBLE_VERSIONS; static constexpr const char* DEFAULT_SCHEMA_VERSION = "v0.0"; - static constexpr const size_t DEFAULT_MAX_VNUM = (1ULL << 32); static bool IsBuiltinPlugin(const std::string& plugin_name); @@ -85,7 +84,8 @@ class Schema { const std::vector>& primary_key, const std::vector& strategies = {}, - size_t max_vnum = DEFAULT_MAX_VNUM, const std::string& description = ""); + size_t max_vnum = static_cast(1) << 32, + const std::string& description = ""); void add_edge_label(const std::string& src_label, const std::string& dst_label, From 0b3230f2b213b636875a8ee9fa18e397a5538cf7 Mon Sep 17 00:00:00 2001 From: "xiaolei.zl" Date: Thu, 24 Oct 2024 13:14:57 +0800 Subject: [PATCH 5/5] use .capacity() Committed-by: xiaolei.zl from Dev container --- flex/storages/rt_mutable_graph/mutable_property_fragment.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc index c912fa5c3c2f..1cb2c329efd5 100644 --- a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc +++ b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc @@ -192,7 +192,8 @@ void MutablePropertyFragment::Open(const std::string& work_dir, } // We will reserve the at least 4096 slots for each vertex label - size_t vertex_capacity = std::max(lf_indexers_[i].size(), (size_t) 4096); + size_t vertex_capacity = + std::max(lf_indexers_[i].capacity(), (size_t) 4096); if (vertex_capacity >= lf_indexers_[i].size()) { lf_indexers_[i].reserve(vertex_capacity); }