Visitar URL original
Lazy heap by jounathaen · Pull Request #2759 · hermit-os/kernel · GitHub
Skip to content

Lazy heap - #2759

Draft
jounathaen wants to merge 6 commits into
mainfrom
lazy_heap
Draft

jounathaen wants to merge 6 commits into
mainfrom
lazy_heap

Conversation

@jounathaen

Copy link
Copy Markdown
Member

Depends on #2758

Fixes #2740

Instead of giving 90% of the physical memory to the heap and reserving 10% for the kernel, we now only reserve a little portion for the heap but grow the heap once it runs out of memory.
To avoid deadlocks that can occur if allocations in the FreeList cause a grow on the heap, we have to replace the FreeList with an (allocation-free) bitmap (see #2758).

jounathaen and others added 6 commits October 30, 2026 15:45
This guarantees the absence of allocations when managing frames.

Assisted-by: Anthropic Claude
Instead of pre-allocating all physical pages, this only maps them once
the current heap runs out of physical pages. This keeps physical memory
available for other uses, such as task stacks and network queues.

Fixes #2740

Assisted-by: Anthropic Claude

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark Results

Details
Benchmark Current: d99e357 Previous: 2e23902 Performance Ratio
startup_benchmark Build Time 86.12 s 80.34 s 1.07 ❗
startup_benchmark File Size 0.85 MB 0.80 MB 1.07 ❗
Startup Time - 1 core 0.73 s (±0.02 s) 0.75 s (±0.02 s) 0.98
Startup Time - 2 cores 0.74 s (±0.02 s) 0.74 s (±0.02 s) 1.00
Startup Time - 4 cores 0.72 s (±0.03 s) 0.74 s (±0.02 s) 0.98
multithreaded_benchmark Build Time 84.16 s 82.11 s 1.02 ❗
multithreaded_benchmark File Size 0.94 MB 0.86 MB 1.10 ❗
Multithreaded Pi Efficiency - 2 Threads 87.92 % (±8.62 %) 85.89 % (±6.61 %) 1.02
Multithreaded Pi Efficiency - 4 Threads 44.79 % (±2.42 %) 43.43 % (±2.56 %) 1.03
Multithreaded Pi Efficiency - 8 Threads 26.13 % (±1.60 %) 25.76 % (±1.53 %) 1.01
micro_benchmarks Build Time 83.86 s 80.40 s 1.04 ❗
micro_benchmarks File Size 0.95 MB 0.86 MB 1.10 ❗
Scheduling time - 1 thread 64.68 ticks (±3.09 ticks) 62.65 ticks (±4.06 ticks) 1.03
Scheduling time - 2 threads 35.67 ticks (±5.28 ticks) 34.08 ticks (±4.10 ticks) 1.05
Micro - Time for syscall (getpid) 3.58 ticks (±0.57 ticks) 3.45 ticks (±0.58 ticks) 1.04
Memcpy speed - (built_in) block size 4096 84199.26 MByte/s (±58211.14 MByte/s) 82448.38 MByte/s (±56997.13 MByte/s) 1.02
Memcpy speed - (built_in) block size 1048576 30378.32 MByte/s (±24397.98 MByte/s) 30585.98 MByte/s (±24707.84 MByte/s) 0.99
Memcpy speed - (built_in) block size 16777216 29005.41 MByte/s (±23874.50 MByte/s) 26340.06 MByte/s (±21720.96 MByte/s) 1.10
Memset speed - (built_in) block size 4096 84003.29 MByte/s (±58079.40 MByte/s) 82292.76 MByte/s (±56891.50 MByte/s) 1.02
Memset speed - (built_in) block size 1048576 31112.90 MByte/s (±24824.29 MByte/s) 31323.85 MByte/s (±25145.86 MByte/s) 0.99
Memset speed - (built_in) block size 16777216 29727.08 MByte/s (±24275.43 MByte/s) 27104.68 MByte/s (±22209.94 MByte/s) 1.10
Memcpy speed - (rust) block size 4096 77343.43 MByte/s (±53685.26 MByte/s) 74097.96 MByte/s (±51811.44 MByte/s) 1.04
Memcpy speed - (rust) block size 1048576 30016.37 MByte/s (±24306.74 MByte/s) 30361.60 MByte/s (±24602.37 MByte/s) 0.99
Memcpy speed - (rust) block size 16777216 28879.20 MByte/s (±23750.47 MByte/s) 27625.34 MByte/s (±22806.88 MByte/s) 1.05
Memset speed - (rust) block size 4096 77508.85 MByte/s (±53779.30 MByte/s) 74373.47 MByte/s (±51976.48 MByte/s) 1.04
Memset speed - (rust) block size 1048576 30744.27 MByte/s (±24725.54 MByte/s) 31110.89 MByte/s (±25033.24 MByte/s) 0.99
Memset speed - (rust) block size 16777216 29640.61 MByte/s (±24189.44 MByte/s) 28386.93 MByte/s (±23265.03 MByte/s) 1.04
alloc_benchmarks Build Time 84.22 s 74.76 s 1.13 ❗
alloc_benchmarks File Size 0.92 MB 0.87 MB 1.06 ❗
Allocations - Allocation success 93.15 % 91.31 % 1.02 ❗
Allocations - Deallocation success 100.00 % 100.00 % 1
Allocations - Pre-fail Allocations 68.68 % 61.44 % 1.12 ❗
Allocations - Average Allocation time 4894.14 Ticks (±582.53 Ticks) 5860.58 Ticks (±98.43 Ticks) 0.84 ❗
Allocations - Average Allocation time (no fail) 5653.92 Ticks (±541.93 Ticks) 6554.81 Ticks (±92.86 Ticks) 0.86 ❗
Allocations - Average Deallocation time 2078.91 Ticks (±214.78 Ticks) 1805.01 Ticks (±250.35 Ticks) 1.15
mutex_benchmark Build Time 95.08 s 79.82 s 1.19 ❗
mutex_benchmark File Size 0.95 MB 0.86 MB 1.10 ❗
Mutex Stress Test Average Time per Iteration - 1 Threads 12.20 ns (±0.40 ns) 12.10 ns (±0.41 ns) 1.01
Mutex Stress Test Average Time per Iteration - 2 Threads 66.84 ns (±2.85 ns) 40.26 ns (±1.68 ns) 1.66 ❗

This comment was automatically generated by workflow using github-action-benchmark.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

static 10% reserve of heap memory for device & stack is inefficient and causes issues.

1 participant