Skip to content

Conversation

@m-mueller678
Copy link
Contributor

@m-mueller678 m-mueller678 commented Oct 19, 2025

This PR introduces an API to abstract allocation and deallocation in KERNEL_FREE_LIST and PHYSICAL_FREE_LIST. Changes are intended to be a pure refactoring with no changes in behaviour. Abstracting the free lists makes it easier to replace them with concurrent data structures in the future.

This is part of the plan laid out in #1993.
This implementation is based on #1991.

@mkroening mkroening self-assigned this Oct 19, 2025
@mkroening mkroening self-requested a review October 19, 2025 12:18
@m-mueller678 m-mueller678 force-pushed the allocator-abstraction branch from 5186815 to f306571 Compare October 19, 2025 13:00
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Benchmark Results

Benchmark Current: 7cc0128 Previous: c98578c Performance Ratio
startup_benchmark Build Time 112.91 s 112.25 s 1.01
startup_benchmark File Size 0.91 MB 0.89 MB 1.02
Startup Time - 1 core 0.88 s (±0.04 s) 0.90 s (±0.03 s) 0.98
Startup Time - 2 cores 0.88 s (±0.04 s) 0.90 s (±0.03 s) 0.98
Startup Time - 4 cores 0.91 s (±0.04 s) 0.91 s (±0.03 s) 1.01
multithreaded_benchmark Build Time 114.75 s 110.14 s 1.04
multithreaded_benchmark File Size 1.01 MB 1.00 MB 1.01
Multithreaded Pi Efficiency - 2 Threads 85.62 % (±8.76 %) 92.81 % (±5.78 %) 0.92
Multithreaded Pi Efficiency - 4 Threads 43.56 % (±3.63 %) 45.41 % (±2.15 %) 0.96
Multithreaded Pi Efficiency - 8 Threads 24.83 % (±1.58 %) 25.87 % (±0.96 %) 0.96
micro_benchmarks Build Time 114.35 s 120.17 s 0.95
micro_benchmarks File Size 1.01 MB 1.00 MB 1.01
Scheduling time - 1 thread 71.47 ticks (±4.50 ticks) 74.49 ticks (±4.52 ticks) 0.96
Scheduling time - 2 threads 41.13 ticks (±5.49 ticks) 40.83 ticks (±3.64 ticks) 1.01
Micro - Time for syscall (getpid) 3.24 ticks (±0.44 ticks) 4.23 ticks (±0.55 ticks) 0.77
Memcpy speed - (built_in) block size 4096 65446.59 MByte/s (±47131.02 MByte/s) 60953.02 MByte/s (±43546.15 MByte/s) 1.07
Memcpy speed - (built_in) block size 1048576 29549.15 MByte/s (±24315.32 MByte/s) 28671.28 MByte/s (±23808.71 MByte/s) 1.03
Memcpy speed - (built_in) block size 16777216 25238.39 MByte/s (±21228.37 MByte/s) 21629.65 MByte/s (±18202.58 MByte/s) 1.17
Memset speed - (built_in) block size 4096 66323.21 MByte/s (±47619.65 MByte/s) 61354.19 MByte/s (±43777.21 MByte/s) 1.08
Memset speed - (built_in) block size 1048576 30346.00 MByte/s (±24750.06 MByte/s) 29512.24 MByte/s (±24319.97 MByte/s) 1.03
Memset speed - (built_in) block size 16777216 26023.87 MByte/s (±21730.74 MByte/s) 22292.68 MByte/s (±18645.03 MByte/s) 1.17
Memcpy speed - (rust) block size 4096 59799.65 MByte/s (±43764.69 MByte/s) 56885.86 MByte/s (±41858.13 MByte/s) 1.05
Memcpy speed - (rust) block size 1048576 29170.79 MByte/s (±24054.14 MByte/s) 28476.97 MByte/s (±23846.47 MByte/s) 1.02
Memcpy speed - (rust) block size 16777216 24119.18 MByte/s (±20211.84 MByte/s) 23424.95 MByte/s (±19786.13 MByte/s) 1.03
Memset speed - (rust) block size 4096 60876.58 MByte/s (±44503.53 MByte/s) 57746.63 MByte/s (±42387.57 MByte/s) 1.05
Memset speed - (rust) block size 1048576 29945.13 MByte/s (±24508.26 MByte/s) 29279.25 MByte/s (±24297.01 MByte/s) 1.02
Memset speed - (rust) block size 16777216 24888.79 MByte/s (±20729.22 MByte/s) 24162.64 MByte/s (±20274.04 MByte/s) 1.03
alloc_benchmarks Build Time 106.56 s 116.82 s 0.91
alloc_benchmarks File Size 0.97 MB 0.95 MB 1.02
Allocations - Allocation success 100.00 % 100.00 % 1
Allocations - Deallocation success 69.94 % (±0.23 %) 69.95 % (±0.24 %) 1.00
Allocations - Pre-fail Allocations 100.00 % 100.00 % 1
Allocations - Average Allocation time 10368.03 Ticks (±149.73 Ticks) 10358.23 Ticks (±157.44 Ticks) 1.00
Allocations - Average Allocation time (no fail) 10368.03 Ticks (±149.73 Ticks) 10358.23 Ticks (±157.44 Ticks) 1.00
Allocations - Average Deallocation time 907.56 Ticks (±233.34 Ticks) 894.39 Ticks (±206.54 Ticks) 1.01
mutex_benchmark Build Time 105.86 s 111.85 s 0.95
mutex_benchmark File Size 1.01 MB 1.01 MB 1.01
Mutex Stress Test Average Time per Iteration - 1 Threads 12.56 ns (±0.78 ns) 13.24 ns (±0.62 ns) 0.95
Mutex Stress Test Average Time per Iteration - 2 Threads 13.32 ns (±1.12 ns) 14.44 ns (±1.04 ns) 0.92

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

@m-mueller678 m-mueller678 force-pushed the allocator-abstraction branch from 73121ae to da36d1b Compare October 19, 2025 15:08
@m-mueller678 m-mueller678 marked this pull request as ready for review October 19, 2025 15:42
@m-mueller678 m-mueller678 force-pushed the allocator-abstraction branch from da36d1b to 5dd7888 Compare October 20, 2025 09:20
@m-mueller678 m-mueller678 force-pushed the allocator-abstraction branch from 87e8473 to 54bcea6 Compare October 20, 2025 12:56
@m-mueller678 m-mueller678 force-pushed the allocator-abstraction branch from 54bcea6 to 3484492 Compare October 20, 2025 13:02
Copy link
Member

@mkroening mkroening left a comment

Choose a reason for hiding this comment

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

I really like extracting an abstraction for this! This is essentially reverting #1828, though. I don't think free-standing functions are a good fit here.

A while ago, I also started working on adding back an allocator-like abstraction. Let's discuss that once I have rebased and completed it (maybe later today, possibly later this week). :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants