From 30b82b7694a1d18da5899b7a4b885d9d4614babe Mon Sep 17 00:00:00 2001 From: MarieENSG Date: Fri, 27 Mar 2026 15:29:55 +0100 Subject: [PATCH 1/9] fix(ExplicitVariability): change many Flat_hash_map container into Btree_map to prevent variability in the results --- include/geode/basic/mapping.hpp | 21 ++++++++++--------- .../geode/model/mixin/core/component_type.hpp | 9 ++++++++ .../model/mixin/core/vertex_identifier.hpp | 2 ++ .../mesh/helpers/convert_surface_mesh.cpp | 2 ++ .../model/mixin/core/vertex_identifier.cpp | 10 +++++++++ 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/include/geode/basic/mapping.hpp b/include/geode/basic/mapping.hpp index fb520cb3b..cba1425f4 100644 --- a/include/geode/basic/mapping.hpp +++ b/include/geode/basic/mapping.hpp @@ -23,7 +23,8 @@ #pragma once -#include +#include +#include #include #include @@ -39,10 +40,10 @@ namespace geode template < typename T > using Storage = typename StorageType< T >::Type; - void reserve( index_t capacity ) + void reserve( index_t /* capacity */ ) { - in2out_.reserve( capacity ); - out2in_.reserve( capacity ); + // in2out_.reserve( capacity ); + // out2in_.reserve( capacity ); } void clear() @@ -71,13 +72,13 @@ namespace geode return out2in_.at( out ); } - [[nodiscard]] const absl::flat_hash_map< T1, Storage< T2 > >& + [[nodiscard]] const absl::btree_map< T1, Storage< T2 > >& in2out_map() const { return in2out_; } - [[nodiscard]] const absl::flat_hash_map< T2, Storage< T1 > >& + [[nodiscard]] const absl::btree_map< T2, Storage< T1 > >& out2in_map() const { return out2in_; @@ -100,19 +101,19 @@ namespace geode return static_cast< index_t >( out2in_.size() ); } - [[nodiscard]] absl::flat_hash_map< T1, Storage< T2 > >& in2out_mapping() + [[nodiscard]] absl::btree_map< T1, Storage< T2 > >& in2out_mapping() { return in2out_; } - [[nodiscard]] absl::flat_hash_map< T2, Storage< T1 > >& out2in_mapping() + [[nodiscard]] absl::btree_map< T2, Storage< T1 > >& out2in_mapping() { return out2in_; } private: - absl::flat_hash_map< T1, Storage< T2 > > in2out_; - absl::flat_hash_map< T2, Storage< T1 > > out2in_; + absl::btree_map< T1, Storage< T2 > > in2out_; + absl::btree_map< T2, Storage< T1 > > out2in_; }; template < typename T > diff --git a/include/geode/model/mixin/core/component_type.hpp b/include/geode/model/mixin/core/component_type.hpp index 41b99333e..ee4fbf240 100644 --- a/include/geode/model/mixin/core/component_type.hpp +++ b/include/geode/model/mixin/core/component_type.hpp @@ -84,6 +84,15 @@ namespace geode return type_.get() == other.type_.get() && id_ == other.id_; } + [[nodiscard]] bool operator<( const ComponentID& other ) const + { + if( type_.get() != other.type_.get() ) + { + return type_.get() < other.type_.get(); + } + return id_.string() < other.id_.string(); + } + [[nodiscard]] std::string string() const { return absl::StrCat( type_.get(), " ", id_.string() ); diff --git a/include/geode/model/mixin/core/vertex_identifier.hpp b/include/geode/model/mixin/core/vertex_identifier.hpp index 5d7e03be3..324408fe9 100644 --- a/include/geode/model/mixin/core/vertex_identifier.hpp +++ b/include/geode/model/mixin/core/vertex_identifier.hpp @@ -57,6 +57,8 @@ namespace geode [[nodiscard]] bool operator==( const ComponentMeshVertex& other ) const; + [[nodiscard]] bool operator<( const ComponentMeshVertex& other ) const; + template < typename Archive > void serialize( Archive& archive ); diff --git a/src/geode/mesh/helpers/convert_surface_mesh.cpp b/src/geode/mesh/helpers/convert_surface_mesh.cpp index 645948cc3..8da322e02 100644 --- a/src/geode/mesh/helpers/convert_surface_mesh.cpp +++ b/src/geode/mesh/helpers/convert_surface_mesh.cpp @@ -23,6 +23,8 @@ #include +#include + #include #include diff --git a/src/geode/model/mixin/core/vertex_identifier.cpp b/src/geode/model/mixin/core/vertex_identifier.cpp index 152ca4282..a698b9e5d 100644 --- a/src/geode/model/mixin/core/vertex_identifier.cpp +++ b/src/geode/model/mixin/core/vertex_identifier.cpp @@ -78,6 +78,16 @@ namespace geode return component_id == other.component_id && vertex == other.vertex; } + bool ComponentMeshVertex::operator<( + const ComponentMeshVertex& other ) const + { + if( component_id != other.component_id ) + { + return component_id < other.component_id; + } + return vertex < other.vertex; + } + template < typename Archive > void ComponentMeshVertex::serialize( Archive& archive ) { From 0515c29714b8a04cb3e8ebdb0ad7d1503dd0ccb2 Mon Sep 17 00:00:00 2001 From: MarieENSG <196926038+MarieENSG@users.noreply.github.com> Date: Fri, 27 Mar 2026 14:47:25 +0000 Subject: [PATCH 2/9] Apply prepare changes --- .clang-tidy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index b0398498e..566fa5b22 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -19,7 +19,8 @@ Checks: > -readability-use-anyofallof, -readability-redundant-access-specifiers, -readability-convert-member-functions-to-static, - -cppcoreguidelines-avoid-const-or-ref-data-members + -cppcoreguidelines-avoid-const-or-ref-data-members, + -cppcoreguidelines-pro-bounds-constant-array-index CheckOptions: - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic From 7cea3131fe8fe5232f1bbe98977c1ab486cadd37 Mon Sep 17 00:00:00 2001 From: MarieENSG Date: Mon, 30 Mar 2026 10:54:27 +0200 Subject: [PATCH 3/9] fix bug in unmap() --- include/geode/basic/mapping.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/geode/basic/mapping.hpp b/include/geode/basic/mapping.hpp index cba1425f4..b17b8c649 100644 --- a/include/geode/basic/mapping.hpp +++ b/include/geode/basic/mapping.hpp @@ -226,6 +226,11 @@ namespace geode } auto& out_map = this->out2in_mapping().at( out ); const auto itr2 = absl::c_find( out_map, in ); + DEBUG( itr2 == out_map.end() ); + if( itr2 == out_map.end() ) + { + return; + } out_map.erase( itr2 ); if( this->out2in( out ).empty() ) { From fc0807f329b984459e35d119121f0cd61f1a4336 Mon Sep 17 00:00:00 2001 From: MarieENSG Date: Mon, 30 Mar 2026 14:37:19 +0200 Subject: [PATCH 4/9] review --- include/geode/basic/mapping.hpp | 3 +-- include/geode/model/mixin/core/component_type.hpp | 2 +- src/geode/mesh/helpers/detail/split_along_solid_facets.cpp | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/geode/basic/mapping.hpp b/include/geode/basic/mapping.hpp index b17b8c649..4be9696d2 100644 --- a/include/geode/basic/mapping.hpp +++ b/include/geode/basic/mapping.hpp @@ -40,7 +40,7 @@ namespace geode template < typename T > using Storage = typename StorageType< T >::Type; - void reserve( index_t /* capacity */ ) + [[deprecated]] void reserve( index_t capacity ) { // in2out_.reserve( capacity ); // out2in_.reserve( capacity ); @@ -226,7 +226,6 @@ namespace geode } auto& out_map = this->out2in_mapping().at( out ); const auto itr2 = absl::c_find( out_map, in ); - DEBUG( itr2 == out_map.end() ); if( itr2 == out_map.end() ) { return; diff --git a/include/geode/model/mixin/core/component_type.hpp b/include/geode/model/mixin/core/component_type.hpp index ee4fbf240..0a27d659b 100644 --- a/include/geode/model/mixin/core/component_type.hpp +++ b/include/geode/model/mixin/core/component_type.hpp @@ -90,7 +90,7 @@ namespace geode { return type_.get() < other.type_.get(); } - return id_.string() < other.id_.string(); + return id_ < other.id_; } [[nodiscard]] std::string string() const diff --git a/src/geode/mesh/helpers/detail/split_along_solid_facets.cpp b/src/geode/mesh/helpers/detail/split_along_solid_facets.cpp index e458e109a..bde7de751 100644 --- a/src/geode/mesh/helpers/detail/split_along_solid_facets.cpp +++ b/src/geode/mesh/helpers/detail/split_along_solid_facets.cpp @@ -139,7 +139,6 @@ namespace geode ElementsMapping duplicate_points( const SolidInfo& solid_info ) { ElementsMapping vertices_mapping; - vertices_mapping.reserve( solid_.nb_vertices() ); for( const auto vertex_id : Range{ solid_.nb_vertices() } ) { vertices_mapping.map( vertex_id, vertex_id ); From 1e916a0b03b4b2f6f2326d1a514f40ef86bd39c0 Mon Sep 17 00:00:00 2001 From: MarieENSG Date: Mon, 30 Mar 2026 14:52:34 +0200 Subject: [PATCH 5/9] fix --- include/geode/basic/mapping.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/geode/basic/mapping.hpp b/include/geode/basic/mapping.hpp index 4be9696d2..afbfa8dd1 100644 --- a/include/geode/basic/mapping.hpp +++ b/include/geode/basic/mapping.hpp @@ -42,8 +42,8 @@ namespace geode [[deprecated]] void reserve( index_t capacity ) { - // in2out_.reserve( capacity ); - // out2in_.reserve( capacity ); + in2out_.reserve( capacity ); + out2in_.reserve( capacity ); } void clear() From 0d5a73d62e5ceda2380334dc93fb165aef679bb4 Mon Sep 17 00:00:00 2001 From: MarieENSG Date: Mon, 30 Mar 2026 16:54:25 +0200 Subject: [PATCH 6/9] fix(ExplicitVariability): change many Flat_hash_map container into Btree_map to prevent variability in the results From 9c438599eb9e7c2b374f447927983110861e1eec Mon Sep 17 00:00:00 2001 From: Pierre Anquez Date: Tue, 31 Mar 2026 11:54:50 +0200 Subject: [PATCH 7/9] reserve --- include/geode/basic/mapping.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/geode/basic/mapping.hpp b/include/geode/basic/mapping.hpp index afbfa8dd1..115426655 100644 --- a/include/geode/basic/mapping.hpp +++ b/include/geode/basic/mapping.hpp @@ -42,8 +42,7 @@ namespace geode [[deprecated]] void reserve( index_t capacity ) { - in2out_.reserve( capacity ); - out2in_.reserve( capacity ); + geode_unused( capacity ); } void clear() From 56a5671e47026fe9df9d67f6a16b42e4542f1832 Mon Sep 17 00:00:00 2001 From: Pierre Anquez Date: Thu, 2 Apr 2026 08:58:18 +0200 Subject: [PATCH 8/9] updqte to linked hash --- include/geode/basic/attribute_manager.hpp | 8 ++++---- include/geode/basic/cached_value.hpp | 2 +- include/geode/basic/mapping.hpp | 16 +++++++++------- .../mixin/core/detail/components_storage.hpp | 4 ++-- src/geode/basic/CMakeLists.txt | 1 + src/geode/basic/attribute_manager.cpp | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/geode/basic/attribute_manager.hpp b/include/geode/basic/attribute_manager.hpp index b1da00dc7..60907632c 100644 --- a/include/geode/basic/attribute_manager.hpp +++ b/include/geode/basic/attribute_manager.hpp @@ -60,7 +60,7 @@ namespace geode [[nodiscard]] std::shared_ptr< AttributeBase > find_generic_attribute( std::string_view name ) const { - absl::ReaderMutexLock lock{ &mutex() }; + absl::ReaderMutexLock lock{ mutex() }; return find_attribute_base( name ); } @@ -74,7 +74,7 @@ namespace geode [[nodiscard]] std::shared_ptr< ReadOnlyAttribute< T > > find_attribute( std::string_view name ) const { - absl::ReaderMutexLock lock{ &mutex() }; + absl::ReaderMutexLock lock{ mutex() }; auto attribute = std::dynamic_pointer_cast< ReadOnlyAttribute< T > >( find_attribute_base( name ) ); @@ -110,7 +110,7 @@ namespace geode AttributeProperties properties ) { { - absl::ReaderMutexLock lock{ &mutex() }; + absl::ReaderMutexLock lock{ mutex() }; auto attribute = find_attribute_base( name ); auto typed_attribute = std::dynamic_pointer_cast< Attribute< T > >( attribute ); @@ -119,7 +119,7 @@ namespace geode return typed_attribute; } } - absl::MutexLock lock{ &mutex() }; + absl::MutexLock lock{ mutex() }; auto attribute = find_attribute_base( name ); auto typed_attribute = std::dynamic_pointer_cast< Attribute< T > >( attribute ); diff --git a/include/geode/basic/cached_value.hpp b/include/geode/basic/cached_value.hpp index 27ce2bf71..4294f1e6f 100644 --- a/include/geode/basic/cached_value.hpp +++ b/include/geode/basic/cached_value.hpp @@ -74,7 +74,7 @@ namespace geode { if( !computed_ ) { - absl::MutexLock lock{ &mutex_ }; + absl::MutexLock lock{ mutex_ }; if( !computed_ ) { value_ = computer( std::forward< Args >( args )... ); diff --git a/include/geode/basic/mapping.hpp b/include/geode/basic/mapping.hpp index 115426655..06d34db32 100644 --- a/include/geode/basic/mapping.hpp +++ b/include/geode/basic/mapping.hpp @@ -24,8 +24,8 @@ #pragma once #include -#include #include +#include #include @@ -71,13 +71,13 @@ namespace geode return out2in_.at( out ); } - [[nodiscard]] const absl::btree_map< T1, Storage< T2 > >& + [[nodiscard]] const absl::linked_hash_map< T1, Storage< T2 > >& in2out_map() const { return in2out_; } - [[nodiscard]] const absl::btree_map< T2, Storage< T1 > >& + [[nodiscard]] const absl::linked_hash_map< T2, Storage< T1 > >& out2in_map() const { return out2in_; @@ -100,19 +100,21 @@ namespace geode return static_cast< index_t >( out2in_.size() ); } - [[nodiscard]] absl::btree_map< T1, Storage< T2 > >& in2out_mapping() + [[nodiscard]] absl::linked_hash_map< T1, Storage< T2 > >& + in2out_mapping() { return in2out_; } - [[nodiscard]] absl::btree_map< T2, Storage< T1 > >& out2in_mapping() + [[nodiscard]] absl::linked_hash_map< T2, Storage< T1 > >& + out2in_mapping() { return out2in_; } private: - absl::btree_map< T1, Storage< T2 > > in2out_; - absl::btree_map< T2, Storage< T1 > > out2in_; + absl::linked_hash_map< T1, Storage< T2 > > in2out_; + absl::linked_hash_map< T2, Storage< T1 > > out2in_; }; template < typename T > diff --git a/include/geode/model/mixin/core/detail/components_storage.hpp b/include/geode/model/mixin/core/detail/components_storage.hpp index e791ef5e8..61f9781ba 100644 --- a/include/geode/model/mixin/core/detail/components_storage.hpp +++ b/include/geode/model/mixin/core/detail/components_storage.hpp @@ -27,8 +27,8 @@ #include #include -#include #include +#include #include #include @@ -52,7 +52,7 @@ namespace geode { public: using ComponentPtr = std::unique_ptr< Component >; - using ComponentsStore = absl::btree_map< uuid, ComponentPtr >; + using ComponentsStore = absl::linked_hash_map< uuid, ComponentPtr >; using Iterator = typename ComponentsStore::const_iterator; [[nodiscard]] index_t nb_components() const diff --git a/src/geode/basic/CMakeLists.txt b/src/geode/basic/CMakeLists.txt index 93b50b166..530c02228 100644 --- a/src/geode/basic/CMakeLists.txt +++ b/src/geode/basic/CMakeLists.txt @@ -109,6 +109,7 @@ add_geode_library( "internal/array_impl.hpp" PUBLIC_DEPENDENCIES absl::flat_hash_map + absl::linked_hash_map absl::strings absl::stacktrace absl::symbolize diff --git a/src/geode/basic/attribute_manager.cpp b/src/geode/basic/attribute_manager.cpp index b568cee7e..0989d08b8 100644 --- a/src/geode/basic/attribute_manager.cpp +++ b/src/geode/basic/attribute_manager.cpp @@ -163,7 +163,7 @@ namespace geode void delete_attribute( std::string_view name ) { - absl::MutexLock lock{ &mutex_ }; + absl::MutexLock lock{ mutex_ }; const auto attribute_it = attributes_.find( name ); if( attribute_it != attributes_.end() ) { From f36f79c97d771cc224ddb317be31983b792dfa29 Mon Sep 17 00:00:00 2001 From: Pierre Anquez Date: Thu, 2 Apr 2026 09:14:27 +0200 Subject: [PATCH 9/9] revert reserve --- include/geode/basic/mapping.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/geode/basic/mapping.hpp b/include/geode/basic/mapping.hpp index 06d34db32..d4890d593 100644 --- a/include/geode/basic/mapping.hpp +++ b/include/geode/basic/mapping.hpp @@ -40,9 +40,10 @@ namespace geode template < typename T > using Storage = typename StorageType< T >::Type; - [[deprecated]] void reserve( index_t capacity ) + void reserve( index_t capacity ) { - geode_unused( capacity ); + in2out_.reserve( capacity ); + out2in_.reserve( capacity ); } void clear()