improve the performance of building page tables#635
improve the performance of building page tables#635simongdavies merged 1 commit intohyperlight-dev:mainfrom
Conversation
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
|
I am curious how much this speeds things up. Do you have any numbers? |
I'll add some in while, this really only shows up when we start to use larger sandboxes and if we remove all the snapshot code, which needs a separate fix that will take longer |
|
These before and after measurements are done after removing the snapshotting code (which has the largest impact on creation/function call with reset time as sandbox size increases, this will be dealt with in a separate PR. The flamegraph is from a simple sample program that creates a sandbox with a 500MB heap and then drops it. The benchmarks show the creation of sandboxes with increasing heap size. FlamegraphBefore After BenchmarkBefore After |
|
@ludfjig ☝️ |
Is that ran with |


This PR reduces the overhead of building page tables and page table entries, especially as the size of a sandboxes memory increases.
This pull request focuses on optimizing memory management in the
src/hyperlight_host/src/mem/mgr.rsfile, particularly improving the efficiency of page table entry (PTE) handling and memory region lookups. Key changes include pre-allocating buffers for PTEs, reducing shared memory writes, and introducing caching for sequential memory region access patterns.Memory Management Optimizations:
vecto store all page table entries (pte_buffer), minimizing shared memory writes by writing the entire buffer in one operation. [1] [2]copy_from_slice. This approach avoids repeated conversions and individual writes, improving performance.Sequential Access Optimization:
get_page_flagsmethod to include a cached region index (cached_region_idx) for faster sequential access. The method first checks the cached region, then adjacent regions, and falls back to binary search for non-sequential access patterns. [1] [2]