From acc926946c2578ab91a1a78ab082181590095c3d Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 24 Jul 2024 00:34:07 -0400 Subject: [PATCH] kernel/vm: Check page->accessed as well as page->usage_count in pre_map. usage_count is set by the page_daemon, and as such isn't often updated. In order to check whether new or "hot" pages are in-use, we need to check their "accessed" flag directly. This is a significant speed improvement, especially in heavily-contended mapped files (e.g. shared libraries in a compile job.) Same benchmark (compile the mime_db and relink HaikuDepot): before (same as previous commit's "after"): real 0m18.789s user 0m14.880s sys 0m8.779s after: real 0m16.615s user 0m13.919s sys 0m5.972s --- src/system/kernel/vm/vm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 0e428e7a88..522dadf3c2 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -2123,7 +2123,7 @@ pre_map_area_pages(VMArea* area, VMCache* cache, break; // skip busy and inactive pages - if (page->busy || page->usage_count == 0) + if (page->busy || (page->usage_count == 0 && !page->accessed)) continue; DEBUG_PAGE_ACCESS_START(page);