[*] 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
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
87 changed files with 368 additions and 254 deletions

View file

@ -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 2018 yuzu Emulator Project
@ -8,7 +8,7 @@
#include <atomic>
#include <memory>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <dynarmic/interface/A64/a64.h>
#include "common/common_types.h"

View file

@ -1,11 +1,11 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <list>
#include <optional>
#include <shared_mutex>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <utility>
#include "common/logging/log.h"
@ -144,7 +144,7 @@ private:
using list_type = std::list<key_type>;
using list_iterator = typename list_type::iterator;
using map_value_type = std::pair<list_iterator, value_type>;
using map_type = std::unordered_map<key_type, map_value_type>;
using map_type = ankerl::unordered_dense::map<key_type, map_value_type>;
template <typename V>
void insert_or_update(const key_type& key, V&& value) {

View file

@ -4,7 +4,7 @@
#pragma once
#include <span>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include <oaknut/code_block.hpp>
#include <oaknut/oaknut.hpp>
@ -46,7 +46,7 @@ enum class PatchMode : u32 {
using ModuleTextAddress = u64;
using PatchTextAddress = u64;
using EntryTrampolines = std::unordered_map<ModuleTextAddress, PatchTextAddress>;
using EntryTrampolines = ankerl::unordered_dense::map<ModuleTextAddress, PatchTextAddress>;
class Patcher {
public:

View file

@ -1,9 +1,12 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <set>
#include <unordered_set>
#include <ankerl/unordered_dense.h>
#include <utility>
#include "core/file_sys/vfs/vfs_layered.h"
@ -60,7 +63,7 @@ std::string LayeredVfsDirectory::GetFullPath() const {
std::vector<VirtualFile> LayeredVfsDirectory::GetFiles() const {
std::vector<VirtualFile> out;
std::unordered_set<std::string> out_names;
ankerl::unordered_dense::set<std::string> out_names;
for (const auto& layer : dirs) {
for (auto& file : layer->GetFiles()) {
@ -76,7 +79,7 @@ std::vector<VirtualFile> LayeredVfsDirectory::GetFiles() const {
std::vector<VirtualDir> LayeredVfsDirectory::GetSubdirectories() const {
std::vector<VirtualDir> out;
std::unordered_set<std::string> out_names;
ankerl::unordered_dense::set<std::string> out_names;
for (const auto& layer : dirs) {
for (const auto& sd : layer->GetSubdirectories()) {

View file

@ -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 2023 yuzu Emulator Project
@ -78,7 +78,7 @@ private:
std::array<DebugWatchpoint, Core::Hardware::NUM_WATCHPOINTS> m_watchpoints{};
std::map<KProcessAddress, u64> m_debug_page_refcounts{};
#ifdef HAS_NCE
std::unordered_map<u64, u64> m_post_handlers{};
ankerl::unordered_dense::map<u64, u64> m_post_handlers{};
#endif
std::unique_ptr<Core::ExclusiveMonitor> m_exclusive_monitor;
Core::Memory::Memory m_memory;
@ -493,7 +493,7 @@ public:
static void Switch(KProcess* cur_process, KProcess* next_process);
#ifdef HAS_NCE
std::unordered_map<u64, u64>& GetPostHandlers() noexcept {
ankerl::unordered_dense::map<u64, u64>& GetPostHandlers() noexcept {
return m_post_handlers;
}
#endif

View file

@ -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
@ -10,7 +10,7 @@
#include <functional>
#include <memory>
#include <thread>
#include <unordered_set>
#include <ankerl/unordered_dense.h>
#include <utility>
#include "common/assert.h"
@ -786,8 +786,8 @@ struct KernelCore::Impl {
std::optional<KObjectNameGlobalData> object_name_global_data;
std::unordered_set<KAutoObject*> registered_objects;
std::unordered_set<KAutoObject*> registered_in_use_objects;
ankerl::unordered_dense::set<KAutoObject*> registered_objects;
ankerl::unordered_dense::set<KAutoObject*> registered_in_use_objects;
std::mutex server_lock;
std::vector<std::unique_ptr<Service::ServerManager>> server_managers;

View file

@ -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
@ -11,7 +11,7 @@
#include <list>
#include <memory>
#include <string>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/polyfill_thread.h"

View file

@ -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 2020 yuzu Emulator Project
@ -7,7 +7,7 @@
#pragma once
#include <array>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/common_funcs.h"
@ -176,6 +176,6 @@ struct WebCommonReturnValue {
};
static_assert(sizeof(WebCommonReturnValue) == 0x1010, "WebCommonReturnValue has incorrect size.");
using WebArgInputTLVMap = std::unordered_map<WebArgInputTLVType, std::vector<u8>>;
using WebArgInputTLVMap = ankerl::unordered_dense::map<WebArgInputTLVType, std::vector<u8>>;
} // namespace Service::AM::Frontend

View file

@ -44,8 +44,8 @@ std::vector<u8> default_logo_small;
std::vector<u8> default_logo_large;
bool default_logos_loaded = false;
std::unordered_map<std::string, std::vector<u8>> news_images_small;
std::unordered_map<std::string, std::vector<u8>> news_images_large;
ankerl::unordered_dense::map<std::string, std::vector<u8>> news_images_small;
ankerl::unordered_dense::map<std::string, std::vector<u8>> news_images_large;
std::mutex images_mutex;

View file

@ -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 2024 yuzu Emulator Project
@ -12,7 +12,7 @@
#include <optional>
#include <span>
#include <string>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/common_types.h"
@ -93,7 +93,7 @@ private:
static s64 Now();
mutable std::mutex mtx;
std::unordered_map<std::string, StoredNews> items;
ankerl::unordered_dense::map<std::string, StoredNews> items;
size_t open_counter{};
};

View file

@ -1,9 +1,12 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "common/fs/fs.h"
#include "core/hle/result.h"
@ -85,7 +88,7 @@ private:
AlbumFileDateTime ConvertToAlbumDateTime(u64 posix_time) const;
bool is_mounted{};
std::unordered_map<AlbumFileId, std::filesystem::path> album_files;
ankerl::unordered_dense::map<AlbumFileId, std::filesystem::path> album_files;
Core::System& system;
};

View file

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
@ -15,7 +15,7 @@
#include <random>
#include <span>
#include <thread>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "common/logging/log.h"
#include "common/socket_types.h"
@ -119,7 +119,7 @@ protected:
std::array<LanStation, StationCountMax> stations;
std::array<NodeLatestUpdate, NodeCountMax> node_changes{};
std::array<u8, NodeCountMax> node_last_states{};
std::unordered_map<MacAddress, NetworkInfo, MACAddressHash> scan_results{};
ankerl::unordered_dense::map<MacAddress, NetworkInfo, MACAddressHash> scan_results{};
NodeInfo node_info{};
NetworkInfo network_info{};
State state{State::None};

View file

@ -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 2018 yuzu Emulator Project
@ -7,7 +7,7 @@
#include <string>
#include <optional>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <boost/container_hash/hash.hpp>
#include "common/logging/log.h"
#include "core/core.h"
@ -331,7 +331,7 @@ private:
};
static_assert(sizeof(LogPacketHeader) == 0x18, "LogPacketHeader is an invalid size");
std::unordered_map<LogPacketHeaderEntry, std::vector<u8>> entries{};
ankerl::unordered_dense::map<LogPacketHeaderEntry, std::vector<u8>> entries{};
LogDestination destination{LogDestination::All};
};

View file

@ -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 2018 yuzu Emulator Project
@ -23,7 +23,7 @@
#include <mutex>
#include <optional>
#include <thread>
#include <unordered_set>
#include <ankerl/unordered_dense.h>
#include <common/settings.h>
#ifdef _WIN32

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-FileCopyrightText: 2022 Skyline Team and Contributors
// SPDX-License-Identifier: GPL-3.0-or-later
@ -6,7 +9,7 @@
#include <deque>
#include <memory>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "core/device_memory_manager.h"
#include "core/hle/service/nvdrv/nvdata.h"

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-FileCopyrightText: 2022 Skyline Team and Contributors
// SPDX-License-Identifier: GPL-3.0-or-later
@ -9,7 +12,7 @@
#include <memory>
#include <mutex>
#include <optional>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <assert.h>
#include "common/bit_field.h"
@ -158,7 +161,7 @@ private:
std::list<std::shared_ptr<Handle>> unmap_queue{};
std::mutex unmap_queue_lock{}; //!< Protects access to `unmap_queue`
std::unordered_map<Handle::Id, std::shared_ptr<Handle>>
ankerl::unordered_dense::map<Handle::Id, std::shared_ptr<Handle>>
handles{}; //!< Main owning map of handles
std::mutex handles_lock; //!< Protects access to `handles`

View file

@ -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: 2021 yuzu Emulator Project
@ -13,7 +13,7 @@
#include <memory>
#include <mutex>
#include <optional>
#include <unordered_set>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/address_space.h"
@ -113,7 +113,7 @@ private:
};
static_assert(sizeof(IoctlRemapEntry) == 20, "IoctlRemapEntry is incorrect size");
std::unordered_set<s64_le> map_buffer_offsets{};
ankerl::unordered_dense::set<s64_le> map_buffer_offsets{};
struct IoctlMapBufferEx {
MappingFlags flags{}; // bit0: fixed_offset, bit2: cacheable

View file

@ -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 2018 yuzu Emulator Project
@ -210,7 +210,7 @@ private:
NvCore::SyncpointManager& syncpoint_manager;
NvCore::NvMap& nvmap;
std::shared_ptr<Tegra::Control::ChannelState> channel_state;
std::unordered_map<DeviceFD, NvCore::SessionId> sessions;
ankerl::unordered_dense::map<DeviceFD, NvCore::SessionId> sessions;
u32 channel_syncpoint;
std::mutex channel_mutex;

View file

@ -1,10 +1,13 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <deque>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/common_types.h"
@ -128,7 +131,7 @@ protected:
NvCore::NvMap& nvmap;
NvCore::ChannelType channel_type;
std::array<u32, MaxSyncPoints> device_syncpoints{};
std::unordered_map<DeviceFD, NvCore::SessionId> sessions;
ankerl::unordered_dense::map<DeviceFD, NvCore::SessionId> sessions;
};
}; // namespace Devices
} // namespace Service::Nvidia

View file

@ -1,10 +1,13 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/common_funcs.h"
#include "common/common_types.h"
@ -115,7 +118,7 @@ private:
NvCore::Container& container;
NvCore::NvMap& file;
std::unordered_map<DeviceFD, NvCore::SessionId> sessions;
ankerl::unordered_dense::map<DeviceFD, NvCore::SessionId> sessions;
};
} // namespace Service::Nvidia::Devices

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2021 yuzu Emulator Project
// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors
// SPDX-License-Identifier: GPL-3.0-or-later
@ -9,7 +12,7 @@
#include <memory>
#include <span>
#include <string>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "common/common_types.h"
#include "core/hle/service/kernel_helpers.h"
@ -100,7 +103,7 @@ private:
/// Id to use for the next open file descriptor.
DeviceFD next_fd = 1;
using FilesContainerType = std::unordered_map<DeviceFD, std::shared_ptr<Devices::nvdevice>>;
using FilesContainerType = ankerl::unordered_dense::map<DeviceFD, std::shared_ptr<Devices::nvdevice>>;
/// Mapping of file descriptors to the devices they reference.
FilesContainerType open_files;
@ -108,7 +111,7 @@ private:
EventInterface events_interface;
std::unordered_map<std::string, std::function<FilesContainerType::iterator(DeviceFD)>> builders;
ankerl::unordered_dense::map<std::string, std::function<FilesContainerType::iterator(DeviceFD)>> builders;
};
void LoopProcess(Core::System& system);

View file

@ -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-3.0-or-later
@ -5,7 +8,7 @@
#include <memory>
#include <mutex>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "common/common_types.h"
#include "core/hle/service/nvnflinger/binder.h"
@ -36,8 +39,8 @@ private:
mutable std::mutex lock;
s32 last_id = 0;
std::unordered_map<s32, std::shared_ptr<android::IBinder>> binders;
std::unordered_map<s32, RefCounts> refcounts;
ankerl::unordered_dense::map<s32, std::shared_ptr<android::IBinder>> binders;
ankerl::unordered_dense::map<s32, RefCounts> refcounts;
};
} // namespace Service::Nvnflinger

View file

@ -4,7 +4,7 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "common/uuid.h"
#include "core/hle/service/cmif_types.h"
@ -54,10 +54,10 @@ private:
}
};
std::unordered_map<AppKey, bool, AppKeyHash> app_auto_transfer_{};
std::unordered_map<Common::UUID, bool> global_auto_upload_{};
std::unordered_map<Common::UUID, bool> global_auto_download_{};
std::unordered_map<AppKey, u8, AppKeyHash> autonomy_task_status_{};
ankerl::unordered_dense::map<AppKey, bool, AppKeyHash> app_auto_transfer_{};
ankerl::unordered_dense::map<Common::UUID, bool> global_auto_upload_{};
ankerl::unordered_dense::map<Common::UUID, bool> global_auto_download_{};
ankerl::unordered_dense::map<AppKey, u8, AppKeyHash> autonomy_task_status_{};
};
} // namespace Service::OLSC

View file

@ -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 2018 yuzu Emulator Project
@ -10,7 +10,7 @@
#include <memory>
#include <mutex>
#include <string>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <concepts>
#include "core/hle/kernel/k_port.h"
@ -97,8 +97,8 @@ private:
/// Map of registered services, retrieved using GetServicePort.
std::mutex lock;
std::unordered_map<std::string, SessionRequestHandlerFactory> registered_services;
std::unordered_map<std::string, Kernel::KClientPort*> service_ports;
ankerl::unordered_dense::map<std::string, SessionRequestHandlerFactory> registered_services;
ankerl::unordered_dense::map<std::string, Kernel::KClientPort*> service_ports;
/// Kernel context
Kernel::KernelCore& kernel;

View file

@ -1,10 +1,13 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "common/common_types.h"
#include "common/polyfill_thread.h"
@ -45,7 +48,7 @@ private:
private:
Core::System& m_system;
Container& m_container;
std::unordered_map<u64, VsyncManager> m_vsync_managers;
ankerl::unordered_dense::map<u64, VsyncManager> m_vsync_managers;
std::shared_ptr<Core::Timing::EventType> m_event;
Common::Event m_signal;
std::jthread m_thread;

View file

@ -8,7 +8,7 @@
#include <mutex>
#include <sstream>
#include <string>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <fmt/format.h>
#include <nlohmann/json.hpp>
@ -21,8 +21,8 @@
namespace Core::LaunchTimestampCache {
namespace {
using CacheMap = std::unordered_map<u64, s64>;
using CountMap = std::unordered_map<u64, u64>;
using CacheMap = ankerl::unordered_dense::map<u64, s64>;
using CountMap = ankerl::unordered_dense::map<u64, u64>;
std::mutex g_mutex;
CacheMap g_cache;