[*] change all std::unordered_map and std::unordered_set into ankerl::unordered_dense::map/set variants (#3442)

mainly doing this to reduce memory footprint; we all know how nice ankerl::unordered_dense is

in theory 4x faster - in practice these maps arent that "hot" anyways so not likely to have much perf gained

i just want to reduce mem fragmentation to ease my porting process, plus it helps other platforms as well (ahem weak Mediatek devices) :)

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

Co-authored-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3442
Reviewed-by: DraVee <dravee@eden-emu.dev>
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie
2026-02-10 03:34:07 +01:00
committed by crueter
parent 0f8b35c4cd
commit a8093c2a3c
87 changed files with 368 additions and 254 deletions
+4 -4
View File
@@ -7,7 +7,7 @@
#pragma once
#include <array>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "common/common_types.h"
#include "shader_recompiler/program_header.h"
@@ -125,9 +125,9 @@ protected:
u32 start_address{};
bool is_proprietary_driver{};
public:
std::unordered_map<CbufWordKey, u32, CbufWordKeyHash> cbuf_word_cache;
std::unordered_map<HandleKey, u32, HandleKeyHash> handle_cache;
std::unordered_map<const IR::Inst*, ConstBufferAddr> track_cache;
ankerl::unordered_dense::map<CbufWordKey, u32, CbufWordKeyHash> cbuf_word_cache;
ankerl::unordered_dense::map<HandleKey, u32, HandleKeyHash> handle_cache;
ankerl::unordered_dense::map<const IR::Inst*, ConstBufferAddr> track_cache;
};
} // namespace Shader
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
@@ -7,7 +7,7 @@
#include <algorithm>
#include <memory>
#include <string>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <utility>
#include <vector>
@@ -390,7 +390,7 @@ private:
std::optional<Node> return_label) {
Statement* const false_stmt{pool.Create(Identity{}, IR::Condition{false}, &root_stmt)};
Tree& root{root_stmt.children};
std::unordered_map<Flow::Block*, Node> local_labels;
ankerl::unordered_dense::map<Flow::Block*, Node> local_labels;
local_labels.reserve(function.blocks.size());
for (Flow::Block& block : function.blocks) {
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -16,7 +19,7 @@
#include <deque>
#include <map>
#include <span>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <variant>
#include <vector>
@@ -50,8 +53,8 @@ struct IndirectBranchVariable {
auto operator<=>(const IndirectBranchVariable&) const noexcept = default;
};
using Variant = std::variant<IR::Reg, IR::Pred, ZeroFlagTag, SignFlagTag, CarryFlagTag,
OverflowFlagTag, GotoVariable, IndirectBranchVariable>;
using Variant = std::variant<IR::Reg, IR::Pred, ZeroFlagTag, SignFlagTag, CarryFlagTag, OverflowFlagTag, GotoVariable, IndirectBranchVariable>;
// TODO: majority of these require stable iterators, test with XC beforehand
using ValueMap = std::unordered_map<IR::Block*, IR::Value>;
struct DefTable {
@@ -112,6 +115,7 @@ struct DefTable {
}
std::array<ValueMap, IR::NUM_USER_PREDS> preds;
// TODO: Requires stable iterators
std::unordered_map<u32, ValueMap> goto_vars;
ValueMap indirect_branch_var;
ValueMap zero_flag;
@@ -165,7 +169,8 @@ public:
template <typename Type>
IR::Value ReadVariable(Type variable, IR::Block* root_block) {
boost::container::small_vector<ReadState<Type>, 64> stack{
// TODO: Windows commits sodoku if you use small_vector
std::vector<ReadState<Type>> stack{
ReadState<Type>(nullptr),
ReadState<Type>(root_block),
};
@@ -295,6 +300,7 @@ private:
return same;
}
// TODO: Windows dies with stack exhaustion?
std::unordered_map<IR::Block*, std::map<Variant, IR::Inst*>> incomplete_phis;
DefTable current_def;
};
@@ -7,7 +7,7 @@
#include <algorithm>
#include <bit>
#include <optional>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <tuple>
#include <limits>
#include <boost/container/small_vector.hpp>