aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2026-01-13 00:27:31 +0100
committercrueter <crueter@eden-emu.dev>2026-01-13 00:27:31 +0100
commitdceeccd04bb11bf4f719a7d403f43f6ebf153f49 (patch)
treead33a8c9bfa5aabec342f8b927b987e77a07e1ac /src/common
parent1cb8bcf531f6ad1b0afcc3b2179a136535760984 (diff)
[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 <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>
Diffstat (limited to 'src/common')
-rw-r--r--src/common/page_table.cpp43
-rw-r--r--src/common/page_table.h25
2 files changed, 32 insertions, 36 deletions
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;
}
diff --git a/src/common/page_table.h b/src/common/page_table.h
index 5340f7d863..3124b4a7fb 100644
--- a/src/common/page_table.h
+++ b/src/common/page_table.h
@@ -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
@@ -75,7 +78,7 @@ struct PageTable {
/// Write a page pointer and type pair atomically
void Store(uintptr_t pointer, PageType type) noexcept {
- raw.store(pointer | static_cast<uintptr_t>(type));
+ raw.store(pointer | uintptr_t(type));
}
/// Unpack a pointer from a page info raw representation
@@ -124,18 +127,20 @@ struct PageTable {
return false;
}
- *out_phys_addr = backing_addr[virt_addr / page_size] + GetInteger(virt_addr);
+ *out_phys_addr = entries[virt_addr / page_size].addr + GetInteger(virt_addr);
return true;
}
- /**
- * Vector of memory pointers backing each page. An entry can only be non-null if the
- * corresponding attribute element is of type `Memory`.
- */
- VirtualBuffer<PageInfo> pointers;
- VirtualBuffer<u64> blocks;
-
- VirtualBuffer<u64> backing_addr;
+ /// Vector of memory pointers backing each page. An entry can only be non-null if the
+ /// corresponding attribute element is of type `Memory`.
+ struct PageEntryData {
+ PageInfo ptr;
+ u64 block;
+ u64 addr;
+ u64 padding;
+ };
+ VirtualBuffer<PageEntryData> entries;
+ static_assert(sizeof(PageEntryData) == 32);
std::size_t current_address_space_width_in_bits{};