Skip to content

Use slab allocator for kernel heap

Jeremy Soller requested to merge weclaw1:master into master

Created by: weclaw1

Changes current linked list allocator for slab allocator. Allocations <= 4096 bytes are made in fixed size blocks, >4096 bytes use current allocator.

Here are the benchmark results:

test allocate_many_small_blocks_linked_list            ... bench:   8,904,698 ns/iter (+/- 523,010)
test allocate_many_small_blocks_slab                   ... bench:   2,884,013 ns/iter (+/- 120,920)
test allocate_multiple_sizes_linked_list_over_4096     ... bench:       2,151 ns/iter (+/- 166)
test allocate_multiple_sizes_linked_list_up_to_4096    ... bench:      23,771 ns/iter (+/- 1,712)
test allocate_multiple_sizes_linked_list_various_sizes ... bench:       7,120 ns/iter (+/- 606)
test allocate_multiple_sizes_slab_over_4096            ... bench:       2,240 ns/iter (+/- 83)
test allocate_multiple_sizes_slab_up_to_4096           ... bench:      15,849 ns/iter (+/- 808)
test allocate_multiple_sizes_slab_various_sizes        ... bench:       5,495 ns/iter (+/- 245)

This allocator gives about 40% speedup for small allocations. Slabs can grow using non-contiguous memory, space for allocations >4096 bytes also can grow, but new memory has to be directly after the old one.

Benchmark can be found here: https://github.com/weclaw1/allocator-benchmark

Merge request reports