extra buffer precautions to not exhaust DMem, format better + perf history nerf
This commit is contained in:
parent
a31891308e
commit
f77bbc64f1
|
|
@ -33,9 +33,6 @@ struct Fiber::FiberImpl {
|
|||
boost::context::detail::fcontext_t 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::function<void()> entry_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) {
|
||||
return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second;
|
||||
}); 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);
|
||||
// should replace the existing mapping... ugh
|
||||
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);
|
||||
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 {
|
||||
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 {
|
||||
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 {}
|
||||
#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 {
|
||||
#ifdef _WIN32
|
||||
void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
ASSERT(addr != nullptr);
|
||||
#elif defined(__OPENORBIS__)
|
||||
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
LOG_WARNING(HW_Memory, "failed to mmap({} bytes) using swapfile {}", size, swapfile_names[swapfile_count]);
|
||||
// int fd = open(swapfile_names[swapfile_count], O_TRUNC | O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
|
||||
// ASSERT(fd > 0);
|
||||
// ftruncate(fd, size);
|
||||
// addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
// ASSERT(addr != MAP_FAILED);
|
||||
// ++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);
|
||||
}
|
||||
// void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
// if (addr == MAP_FAILED) {
|
||||
LOG_WARNING(HW_Memory, "Using VoidMem for {}B area", size);
|
||||
void* 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
|
||||
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
ASSERT(addr != MAP_FAILED);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,11 @@ private:
|
|||
std::size_t current_index{0};
|
||||
/// Stores an hour of historical frametime data useful for processing and tracking performance
|
||||
/// regressions with code changes.
|
||||
#ifdef __OPENORBIS__
|
||||
std::array<double, 60> perf_history{};
|
||||
#else
|
||||
std::array<double, 216000> perf_history{};
|
||||
#endif
|
||||
|
||||
/// Point when the cumulative counters were reset
|
||||
Clock::time_point reset_point = Clock::now();
|
||||
|
|
|
|||
Loading…
Reference in New Issue