Skip to content

HashSet and HashMap use MR::Allocator - #7245

Merged
Fedr merged 6 commits into
masterfrom
hashmap-mimalloc
Oct 25, 2026
Merged

Fedr merged 6 commits into
masterfrom
hashmap-mimalloc

Conversation

@Fedr

@Fedr Fedr commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

HashSet<T> and HashMap<K, V> (and so FaceHashSet, VertHashMap, WholeEdgeHashMap and the rest) now allocate through MR::Allocator, like BitSet blocks since #7240: mimalloc explicitly, or std::allocator in Emscripten builds and with MRMESH_NO_MIMALLOC.

  • MRMeshFwd.h forward-declares MR::Allocator for the aliases; MRPch/MRHashMap.h, the one header that includes phmap, includes MRAllocator.h for its definition. MRAllocator.h now includes config.h instead of MRMeshFwd.h, because the shared precompiled header must not see MRMESH_API that early.
  • MR::Allocator<T> is now a class template deriving from mi_stl_allocator<T> or std::allocator<T>, instead of an alias for one of them, and MR_BIND_IGNORE: the bindings only see it as a template argument of containers. The C bindings are generated once, in the Emscripten image, and compiled on every platform. With the alias they spelled phmap::flat_hash_map<K, V> (Emscripten's std::allocator), which did not match MR::HashMap on native platforms. Now every container type names MR::Allocator<...> on all platforms.
  • BitSet::bits() and BitSet::fromBlocks are bound again: they were hidden in BitSet blocks with the dependencies' non-override mimalloc; one mimalloc per process #7240 for the same Emscripten-vs-native allocator mismatch, not because mrbind ignores custom allocators.
  • ParallelHashSet / ParallelHashMap are unchanged.

Checked locally: MRMesh, MRVoxels and MRViewer build with MSVC with no warnings, and in a test exe without malloc override, BitSet, HashMap (also a copy) and HashSet storage is in the mimalloc heap while plain malloc is not.

🤖 Generated with Claude Code

MRMeshFwd.h includes MRAllocator.h, which now needs only config.h, so the
hash container aliases can name MR::Allocator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Fedr Fedr added full-ci run all steps test-pip-build Build Python wheels (and discard them) labels Oct 24, 2026
Fedr and others added 5 commits October 24, 2026 23:14
The C bindings are generated once in the Emscripten image, where the
alias was std::allocator, so their phmap::flat_hash_map<K, V> did not
match MR::HashMap on native platforms. Now containers name
MR::Allocator<T> everywhere; only its base differs (mi_stl_allocator or
std::allocator).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mrbind's parser aborted with "Duplicate class name: MR::Allocator<M>"; the
bindings only need it as a template argument of containers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
So it no longer pulls mimalloc.h into every file; MRPch/MRHashMap.h, the
one header including phmap, includes MRAllocator.h for the definition.
MRAllocator.h includes config.h, not MRMeshFwd.h, because the shared PCH
must not see MRMESH_API that early.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blocks names MR::Allocator on all platforms now, so the C bindings generated
in the Emscripten image match the native builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Fedr
Fedr merged commit de7f3e8 into master Oct 25, 2026
289 of 291 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci run all steps test-pip-build Build Python wheels (and discard them)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants