mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:57:35 +00:00
Kernel: Optimize VM range deallocation a bit
Previously, when deallocating a range of VM, we would sort and merge the range list. This was quite slow for large processes. This patch optimizes VM deallocation in the following ways: - Use binary search instead of linear scan to find the place to insert the deallocated range. - Insert at the right place immediately, removing the need to sort. - Merge the inserted range with any adjacent range(s) in-line instead of doing a separate merge pass into a list copy. - Add Traits<Range> to inform Vector that Range objects are trivial and can be moved using memmove(). I've also added an assertion that deallocated ranges are actually part of the RangeAllocator's initial address range. I've benchmarked this using g++ to compile Kernel/Process.cpp. With these changes, compilation goes from ~41 sec to ~35 sec.
This commit is contained in:
parent
502626eecb
commit
ad3f931707
4 changed files with 53 additions and 31 deletions
|
@ -27,6 +27,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <Kernel/VM/VirtualAddress.h>
|
||||
|
||||
|
@ -89,9 +90,17 @@ private:
|
|||
void carve_at_index(int, const Range&);
|
||||
|
||||
Vector<Range> m_available_ranges;
|
||||
Range m_total_range;
|
||||
};
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, const Range& value)
|
||||
{
|
||||
return stream << String::format("Range(%x-%x)", value.base().get(), value.end().get() - 1);
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
template<>
|
||||
struct Traits<Range> : public GenericTraits<Range> {
|
||||
static constexpr bool is_trivial() { return true; }
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue