From 5e8e554f948a43d758eee6c0e56ee237f4dc1db1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 12 Nov 2018 15:25:57 +0100 Subject: [PATCH] Add a braindead 10x speedup to kmalloc(). Skip over entirely full buckets when scanning for a big-enough memory slot. This means I can postpone writing a better kmalloc() for a while longer! :^) --- Kernel/kmalloc.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Kernel/kmalloc.cpp b/Kernel/kmalloc.cpp index 367d4fcbe7..e946920818 100644 --- a/Kernel/kmalloc.cpp +++ b/Kernel/kmalloc.cpp @@ -112,6 +112,12 @@ void* kmalloc(dword size) for( i = 0; i < (POOL_SIZE / CHUNK_SIZE / 8); ++i ) { + if (alloc_map[i] == 0xff) { + // Skip over completely full bucket. + chunks_here = 0; + continue; + } + // FIXME: This scan can be optimized further with LZCNT. for( j = 0; j < 8; ++j ) { if( !(alloc_map[i] & (1<