Skip to content

Conversation

@mkroening
Copy link
Member

@mkroening mkroening commented Feb 11, 2026

This PR makes the kernel use early returns in more places as appropriate. This makes the code more readable, as we avoid indentation creep and don't put the happy path into ifs. Handling the exceptional cases earlier and be done with them should also be easier for the brain's stack when reading this code.

This is a rather big commit because of the indentation changes. Semantically, the changes should be much smaller. All changes should be independent.

@mkroening mkroening self-assigned this Feb 11, 2026
@mkroening mkroening force-pushed the early-returns branch 3 times, most recently from e619813 to a613ef5 Compare February 11, 2026 12:59
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

Details
Benchmark Current: 907e825 Previous: 258bff0 Performance Ratio
startup_benchmark Build Time 100.00 s 98.63 s 1.01
startup_benchmark File Size 0.86 MB 0.86 MB 1.00
Startup Time - 1 core 0.96 s (±0.04 s) 0.94 s (±0.03 s) 1.02
Startup Time - 2 cores 0.96 s (±0.03 s) 0.95 s (±0.04 s) 1.01
Startup Time - 4 cores 0.97 s (±0.03 s) 0.97 s (±0.03 s) 1.00
multithreaded_benchmark Build Time 99.03 s 102.84 s 0.96
multithreaded_benchmark File Size 0.96 MB 0.96 MB 1.00
Multithreaded Pi Efficiency - 2 Threads 90.20 % (±8.26 %) 87.52 % (±8.51 %) 1.03
Multithreaded Pi Efficiency - 4 Threads 44.71 % (±3.75 %) 43.60 % (±3.51 %) 1.03
Multithreaded Pi Efficiency - 8 Threads 25.47 % (±1.73 %) 24.84 % (±1.86 %) 1.03
micro_benchmarks Build Time 108.50 s 112.75 s 0.96
micro_benchmarks File Size 0.97 MB 0.97 MB 1.00
Scheduling time - 1 thread 71.76 ticks (±3.84 ticks) 70.01 ticks (±3.16 ticks) 1.02
Scheduling time - 2 threads 39.03 ticks (±4.36 ticks) 39.42 ticks (±5.17 ticks) 0.99
Micro - Time for syscall (getpid) 3.02 ticks (±0.25 ticks) 2.95 ticks (±0.23 ticks) 1.02
Memcpy speed - (built_in) block size 4096 64910.17 MByte/s (±46297.10 MByte/s) 66147.09 MByte/s (±47456.43 MByte/s) 0.98
Memcpy speed - (built_in) block size 1048576 30235.12 MByte/s (±25239.01 MByte/s) 29898.56 MByte/s (±24839.33 MByte/s) 1.01
Memcpy speed - (built_in) block size 16777216 22625.09 MByte/s (±19052.90 MByte/s) 25221.14 MByte/s (±21073.26 MByte/s) 0.90
Memset speed - (built_in) block size 4096 65508.57 MByte/s (±46682.12 MByte/s) 66767.11 MByte/s (±47848.49 MByte/s) 0.98
Memset speed - (built_in) block size 1048576 31091.54 MByte/s (±25737.71 MByte/s) 30679.37 MByte/s (±25280.32 MByte/s) 1.01
Memset speed - (built_in) block size 16777216 22810.76 MByte/s (±19112.77 MByte/s) 26013.80 MByte/s (±21589.28 MByte/s) 0.88
Memcpy speed - (rust) block size 4096 56713.19 MByte/s (±41874.61 MByte/s) 57963.01 MByte/s (±42274.40 MByte/s) 0.98
Memcpy speed - (rust) block size 1048576 30258.31 MByte/s (±25306.94 MByte/s) 30131.39 MByte/s (±25149.51 MByte/s) 1.00
Memcpy speed - (rust) block size 16777216 22303.09 MByte/s (±18739.41 MByte/s) 23049.72 MByte/s (±19442.99 MByte/s) 0.97
Memset speed - (rust) block size 4096 57861.67 MByte/s (±42676.20 MByte/s) 58596.88 MByte/s (±42654.44 MByte/s) 0.99
Memset speed - (rust) block size 1048576 31128.14 MByte/s (±25814.66 MByte/s) 30929.09 MByte/s (±25590.85 MByte/s) 1.01
Memset speed - (rust) block size 16777216 22510.17 MByte/s (±18809.53 MByte/s) 23845.41 MByte/s (±20010.10 MByte/s) 0.94
alloc_benchmarks Build Time 108.72 s 110.10 s 0.99
alloc_benchmarks File Size 0.93 MB 0.93 MB 1.00
Allocations - Allocation success 100.00 % 100.00 % 1
Allocations - Deallocation success 100.00 % 100.00 % 1
Allocations - Pre-fail Allocations 100.00 % 100.00 % 1
Allocations - Average Allocation time 10599.47 Ticks (±194.01 Ticks) 10487.89 Ticks (±195.98 Ticks) 1.01
Allocations - Average Allocation time (no fail) 10599.47 Ticks (±194.01 Ticks) 10487.89 Ticks (±195.98 Ticks) 1.01
Allocations - Average Deallocation time 1207.18 Ticks (±623.08 Ticks) 1237.03 Ticks (±628.80 Ticks) 0.98
mutex_benchmark Build Time 106.01 s 103.43 s 1.02
mutex_benchmark File Size 0.96 MB 0.96 MB 1.00
Mutex Stress Test Average Time per Iteration - 1 Threads 13.70 ns (±0.67 ns) 12.92 ns (±0.56 ns) 1.06
Mutex Stress Test Average Time per Iteration - 2 Threads 16.46 ns (±0.92 ns) 16.02 ns (±0.81 ns) 1.03

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

@mkroening mkroening force-pushed the early-returns branch 5 times, most recently from afce2ea to d7447e3 Compare February 11, 2026 14:36
@mkroening mkroening changed the title refactor: use early returns more refactor: do more early returns Feb 11, 2026
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.

1 participant