mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:27:45 +00:00
LibJS: Recycle up to 64 HeapBlocks to improve performance :^)
This patch adds a BlockAllocator to the GC heap where we now cache up to 64 HeapBlock-sized mmap's that get recycled when allocating HeapBlocks. This improves test-js runtime performance by ~35%, pretty cool! :^)
This commit is contained in:
parent
d2149c153c
commit
e9081a2644
6 changed files with 101 additions and 8 deletions
28
Userland/Libraries/LibJS/Heap/BlockAllocator.h
Normal file
28
Userland/Libraries/LibJS/Heap/BlockAllocator.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Vector.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
class BlockAllocator {
|
||||
public:
|
||||
BlockAllocator();
|
||||
~BlockAllocator();
|
||||
|
||||
void* allocate_block(char const* name);
|
||||
void deallocate_block(void*);
|
||||
|
||||
private:
|
||||
static constexpr size_t max_cached_blocks = 64;
|
||||
|
||||
Vector<void*> m_blocks;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue