From e83979afa4cf62fd7980a863da80be11644feabe Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 3 Aug 2022 17:51:32 -0400 Subject: [PATCH] kernel/fs: Larger sizes for EntryCache if there is >= 1GB RAM available. Instead of 8096 maximum entries, now there will be about 130k. As there are around ~32k files in the Haiku git tree, this has a serious impact on "git status" performance: in my testing it sped up from around 0.95s to 0.39s, or less than half with a "hot" cache (in a VM backed by an NVMe SSD, may be more dramatic on spinning system.) Compile performance does not seem very much improved, however. --- src/system/kernel/fs/EntryCache.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/fs/EntryCache.cpp b/src/system/kernel/fs/EntryCache.cpp index 1552e055cd..c55a0f48eb 100644 --- a/src/system/kernel/fs/EntryCache.cpp +++ b/src/system/kernel/fs/EntryCache.cpp @@ -7,6 +7,7 @@ #include "EntryCache.h" #include +#include static const int32 kEntryNotInArray = -1; @@ -78,8 +79,15 @@ EntryCache::Init() if (error != B_OK) return error; - fGenerationCount = 8; int32 entriesSize = 1024; + fGenerationCount = 8; + + // TODO: Choose generation size/count more scientifically? + // TODO: Add low_resource handler hook? + if (vm_available_memory() >= (1024*1024*1024)) { + entriesSize = 8096; + fGenerationCount = 16; + } fGenerations = new(std::nothrow) EntryCacheGeneration[fGenerationCount]; for (int32 i = 0; i < fGenerationCount; i++) {