Skip to content

Commit

Permalink
Add a braindead 10x speedup to kmalloc().
Browse files Browse the repository at this point in the history
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! :^)
  • Loading branch information
awesomekling committed Nov 12, 2018
1 parent dea474d commit 5e8e554
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Kernel/kmalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<<j)) )
Expand Down

0 comments on commit 5e8e554

Please sign in to comment.