[common] Switch to boost::unordered_flat containers (#4326)

Replaces all instances of ankerl's unordered map/set with boost's
`unordered_flat_*` classes. This uses std::hash since boost::hash is
actually a lot slower.

Also adds an abstraction layer in `Common` so future changes are quicker
and easier.

Other implementation details:
- ankerl provided hash specializations for tuple and pair, so those were
  ported here
- std::erase_if doesn't work on boost, so just used the ADL'd erase_if

This should be about equal or superior performance as unordered_dense for everything except iteration.

Signed-off-by: crueter <crueter@eden-emu.dev>

- [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions).
- [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md)
- [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability.

-------------------

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4326
Reviewed-by: Lizzie and Samuel <lizzie@eden-emu.dev>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
This commit is contained in:
crueter
2026-08-31 02:58:09 +02:00
parent 106a61c943
commit 7fda6dde73
118 changed files with 348 additions and 340 deletions
+2 -2
View File
@@ -8,7 +8,7 @@
#include <array>
#include <exception>
#include <ankerl/unordered_dense.h>
#include "common/container/unordered_map.h"
#include <catch2/catch_test_macros.hpp>
#include "common/common_types.h"
@@ -23,7 +23,7 @@ namespace {
class MyEnvironment final : public A64::UserCallbacks {
public:
u64 ticks_left = 0;
ankerl::unordered_dense::map<u64, u8> memory{};
::Common::unordered_map<u64, u8> memory{};
u8 MemoryRead8(u64 vaddr) override {
return memory[vaddr];
+2 -2
View File
@@ -8,7 +8,7 @@
#pragma once
#include <ankerl/unordered_dense.h>
#include "common/container/unordered_map.h"
#include "common/assert.h"
#include "common/common_types.h"
#include "dynarmic/interface/A64/a64.h"
@@ -17,7 +17,7 @@ using Vector = Dynarmic::A64::Vector;
class A64TestEnv : public Dynarmic::A64::UserCallbacks {
public:
ankerl::unordered_dense::map<u64, u8> modified_memory;
::Common::unordered_map<u64, u8> modified_memory;
std::vector<u32> code_mem;
u64 ticks_left = 0;
u64 code_mem_start_address = 0;
+5 -5
View File
@@ -24,7 +24,7 @@ add_executable(dynarmic_tests
A64/real_world.cpp
A64/testenv.h
)
target_link_libraries(dynarmic_tests PRIVATE merry::oaknut unordered_dense::unordered_dense)
target_link_libraries(dynarmic_tests PRIVATE merry::oaknut)
if (DYNARMIC_TESTS_USE_UNICORN)
target_link_libraries(dynarmic_tests PRIVATE Unicorn::Unicorn)
@@ -72,7 +72,7 @@ add_executable(dynarmic_print_info
print_info.cpp
)
create_target_directory_groups(dynarmic_print_info)
target_link_libraries(dynarmic_print_info PRIVATE dynarmic fmt::fmt unordered_dense::unordered_dense)
target_link_libraries(dynarmic_print_info PRIVATE dynarmic fmt::fmt)
if (BOOST_NO_HEADERS)
target_link_libraries(dynarmic_print_info PRIVATE Boost::variant Boost::icl Boost::pool)
else()
@@ -93,7 +93,7 @@ add_executable(dynarmic_test_generator
create_target_directory_groups(dynarmic_test_generator)
target_link_libraries(dynarmic_test_generator PRIVATE dynarmic fmt::fmt unordered_dense::unordered_dense)
target_link_libraries(dynarmic_test_generator PRIVATE dynarmic fmt::fmt)
if (BOOST_NO_HEADERS)
target_link_libraries(dynarmic_test_generator PRIVATE Boost::variant Boost::icl Boost::pool)
else()
@@ -110,7 +110,7 @@ add_executable(dynarmic_test_reader
test_reader.cpp
)
create_target_directory_groups(dynarmic_test_reader)
target_link_libraries(dynarmic_test_reader PRIVATE dynarmic fmt::fmt unordered_dense::unordered_dense)
target_link_libraries(dynarmic_test_reader PRIVATE dynarmic fmt::fmt)
if (BOOST_NO_HEADERS)
target_link_libraries(dynarmic_test_reader PRIVATE Boost::variant Boost::icl Boost::pool)
else()
@@ -123,7 +123,7 @@ target_compile_definitions(dynarmic_test_reader PRIVATE FMT_USE_USER_DEFINED_LIT
#
create_target_directory_groups(dynarmic_tests)
target_link_libraries(dynarmic_tests PRIVATE dynarmic Catch2::Catch2WithMain fmt::fmt unordered_dense::unordered_dense)
target_link_libraries(dynarmic_tests PRIVATE dynarmic Catch2::Catch2WithMain fmt::fmt)
if (BOOST_NO_HEADERS)
target_link_libraries(dynarmic_tests PRIVATE Boost::variant Boost::icl Boost::pool)
else()