From dceeccd04bb11bf4f719a7d403f43f6ebf153f49 Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 13 Jan 2026 00:27:31 +0100 Subject: [dynarmic, common] pagetable clustering (#3215) Raises the size of each page entry to 32 bytes, however, it merges them into a single structure THEORETICALLY this is better since the access pattern observed corresponds to the program wanting backing_addr/pointers/blocks immediately after one another. This may improve performance at the cost of some extra memory. Another implementation would be to structure only backing_addr/blocks within the same virtual buffer. Alas spamming virtual buffers is evil since each of them is a cache trasher (imagine jumping from wildly different block to wildly different block immediately). Signed-off-by: lizzie lizzie@eden-emu.dev Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3215 Reviewed-by: DraVee Reviewed-by: CamilleLaVey Co-authored-by: lizzie Co-committed-by: lizzie --- src/common/page_table.cpp | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'src/common/page_table.cpp') diff --git a/src/common/page_table.cpp b/src/common/page_table.cpp index 3205eb7dab..d34ba89993 100644 --- a/src/common/page_table.cpp +++ b/src/common/page_table.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -22,37 +25,25 @@ bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* c // Setup invalid defaults. out_entry->phys_addr = 0; out_entry->block_size = page_size; - - // Regardless of whether the page was mapped, advance on exit. - SCOPE_EXIT { - context->next_page += 1; - context->next_offset += page_size; - }; - // Validate that we can read the actual entry. - const auto page = context->next_page; - if (page >= backing_addr.size()) { - return false; + if (auto const page = context->next_page; page < entries.size()) { + // Validate that the entry is mapped. + if (auto const paddr = entries[page].addr; paddr != 0) { + // Populate the results. + out_entry->phys_addr = paddr + context->next_offset; + context->next_page += 1; + context->next_offset += page_size; + return true; + } } - - // Validate that the entry is mapped. - const auto phys_addr = backing_addr[page]; - if (phys_addr == 0) { - return false; - } - - // Populate the results. - out_entry->phys_addr = phys_addr + context->next_offset; - - return true; + context->next_page += 1; + context->next_offset += page_size; + return false; } void PageTable::Resize(std::size_t address_space_width_in_bits, std::size_t page_size_in_bits) { - const std::size_t num_page_table_entries{1ULL - << (address_space_width_in_bits - page_size_in_bits)}; - pointers.resize(num_page_table_entries); - backing_addr.resize(num_page_table_entries); - blocks.resize(num_page_table_entries); + auto const num_page_table_entries = 1ULL << (address_space_width_in_bits - page_size_in_bits); + entries.resize(num_page_table_entries); current_address_space_width_in_bits = address_space_width_in_bits; page_size = 1ULL << page_size_in_bits; } -- cgit v1.2.3