mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-16 10:26:58 +02:00
extra buffer precautions to not exhaust DMem, format better + perf history nerf
This commit is contained in:
parent
707754cdef
commit
d7aee42379
3 changed files with 16 additions and 31 deletions
|
|
@ -33,9 +33,6 @@ struct Fiber::FiberImpl {
|
||||||
boost::context::detail::fcontext_t context{};
|
boost::context::detail::fcontext_t context{};
|
||||||
boost::context::detail::fcontext_t rewind_context{};
|
boost::context::detail::fcontext_t rewind_context{};
|
||||||
|
|
||||||
boost::context::detail::fcontext_t context{};
|
|
||||||
boost::context::detail::fcontext_t rewind_context{};
|
|
||||||
|
|
||||||
std::mutex guard;
|
std::mutex guard;
|
||||||
std::function<void()> entry_point;
|
std::function<void()> entry_point;
|
||||||
std::function<void()> rewind_point;
|
std::function<void()> rewind_point;
|
||||||
|
|
|
||||||
|
|
@ -111,15 +111,15 @@ static void SwapHandler(int sig, void* raw_context) {
|
||||||
if (auto const it = std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) {
|
if (auto const it = std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) {
|
||||||
return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second;
|
return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second;
|
||||||
}); it != swap_regions.end()) {
|
}); it != swap_regions.end()) {
|
||||||
size_t const page_size = 4096 * 8;
|
size_t const page_size = 4096 * 4; //16K
|
||||||
size_t const page_mask = ~(page_size - 1);
|
size_t const page_mask = ~(page_size - 1);
|
||||||
// should replace the existing mapping... ugh
|
// should replace the existing mapping... ugh
|
||||||
void* aligned_addr = reinterpret_cast<void*>(uintptr_t(mctx.mc_addr) & page_mask);
|
void* aligned_addr = reinterpret_cast<void*>(uintptr_t(mctx.mc_addr) & page_mask);
|
||||||
void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
|
void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||||
if (res == MAP_FAILED) {
|
if (res == MAP_FAILED) {
|
||||||
LOG_ERROR(HW_Memory, "FAIL mapped addr {},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second);
|
LOG_ERROR(HW_Memory, "{},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second);
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO(HW_Memory, "OK mapped addr {},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second);
|
LOG_TRACE(HW_Memory, "{},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(HW_Memory, "fault in addr {:#x} at {:#x}", mctx.mc_addr, mctx.mc_rip); // print caller address
|
LOG_ERROR(HW_Memory, "fault in addr {:#x} at {:#x}", mctx.mc_addr, mctx.mc_rip); // print caller address
|
||||||
|
|
@ -133,36 +133,20 @@ void InitSwap() noexcept {
|
||||||
void InitSwap() noexcept {}
|
void InitSwap() noexcept {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char *swapfile_names[] {
|
|
||||||
"/data/eden/games/swap0.bin",
|
|
||||||
"/data/eden/games/swap1.bin",
|
|
||||||
"/data/eden/games/swap2.bin",
|
|
||||||
"/data/eden/games/swap3.bin",
|
|
||||||
"/data/eden/games/swap4.bin"
|
|
||||||
};
|
|
||||||
static size_t swapfile_count = 0;
|
|
||||||
|
|
||||||
void* AllocateMemoryPages(std::size_t size) noexcept {
|
void* AllocateMemoryPages(std::size_t size) noexcept {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE);
|
void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE);
|
||||||
ASSERT(addr != nullptr);
|
ASSERT(addr != nullptr);
|
||||||
#elif defined(__OPENORBIS__)
|
#elif defined(__OPENORBIS__)
|
||||||
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
// void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||||
if (addr == MAP_FAILED) {
|
// if (addr == MAP_FAILED) {
|
||||||
LOG_WARNING(HW_Memory, "failed to mmap({} bytes) using swapfile {}", size, swapfile_names[swapfile_count]);
|
LOG_WARNING(HW_Memory, "Using VoidMem for {}B area", size);
|
||||||
// int fd = open(swapfile_names[swapfile_count], O_TRUNC | O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
|
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0);
|
||||||
// ASSERT(fd > 0);
|
ASSERT(addr != MAP_FAILED);
|
||||||
// ftruncate(fd, size);
|
swap_regions.emplace_back(addr, size);
|
||||||
// addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
|
// } else {
|
||||||
// ASSERT(addr != MAP_FAILED);
|
// LOG_INFO(HW_Memory, "mmap {} bytes", size);
|
||||||
// ++swapfile_count;
|
// }
|
||||||
|
|
||||||
addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0);
|
|
||||||
ASSERT(addr != MAP_FAILED);
|
|
||||||
swap_regions.emplace_back(addr, size);
|
|
||||||
} else {
|
|
||||||
LOG_INFO(HW_Memory, "mmap {} bytes", size);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||||
ASSERT(addr != MAP_FAILED);
|
ASSERT(addr != MAP_FAILED);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,11 @@ private:
|
||||||
std::size_t current_index{0};
|
std::size_t current_index{0};
|
||||||
/// Stores an hour of historical frametime data useful for processing and tracking performance
|
/// Stores an hour of historical frametime data useful for processing and tracking performance
|
||||||
/// regressions with code changes.
|
/// regressions with code changes.
|
||||||
|
#ifdef __OPENORBIS__
|
||||||
|
std::array<double, 60> perf_history{};
|
||||||
|
#else
|
||||||
std::array<double, 216000> perf_history{};
|
std::array<double, 216000> perf_history{};
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Point when the cumulative counters were reset
|
/// Point when the cumulative counters were reset
|
||||||
Clock::time_point reset_point = Clock::now();
|
Clock::time_point reset_point = Clock::now();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue