Browse Source

[host_memory] decrease latency of mapping on linux (#232)

Signed-off-by: lizzie <lizzie@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/232
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
release/0.0.3
lizzie 3 months ago
committed by crueter
parent
commit
25f1f64792
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 7
      src/common/host_memory.cpp

7
src/common/host_memory.cpp

@ -598,12 +598,17 @@ public:
bool ClearBackingRegion(size_t physical_offset, size_t length) { bool ClearBackingRegion(size_t physical_offset, size_t length) {
#ifdef __linux__ #ifdef __linux__
// Only incur syscall cost IF memset would be slower (theshold = 16MiB)
// TODO(lizzie): Smarter way to dynamically get this threshold (broadwell != raptor lake) for example
if (length >= 2097152UL * 8) {
// Set MADV_REMOVE on backing map to destroy it instantly. // Set MADV_REMOVE on backing map to destroy it instantly.
// This also deletes the area from the backing file. // This also deletes the area from the backing file.
int ret = madvise(backing_base + physical_offset, length, MADV_REMOVE); int ret = madvise(backing_base + physical_offset, length, MADV_REMOVE);
ASSERT_MSG(ret == 0, "madvise failed: {}", strerror(errno)); ASSERT_MSG(ret == 0, "madvise failed: {}", strerror(errno));
return true; return true;
} else {
return false;
}
#else #else
return false; return false;
#endif #endif

Loading…
Cancel
Save