You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/this-month/2022-07/index.md
+31
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,37 @@ If you maintain a Rust project related to operating system development and are l
60
60
61
61
In this section, we describe updates to Rust OS projects that are not directly related to the `rust-osdev` organization. Feel free to [create a pull request](https://github.com/rust-osdev/homepage/pulls) with the updates of your OS project for the next post.
62
62
63
+
### Comparison between [`phip1611/simple-chunk-allocator`](https://github.com/phip1611/simple-chunk-allocator) and [`rust-osdev/linked-list-allocator`](https://github.com/rust-osdev/linked-list-allocator)
64
+
65
+
<spanclass="gray">(Section written by [@phip1611](https://github.com/phip1611))</span>
66
+
67
+
In March 2022, Philipp Schuster proposed his [`simple-chunk-allocator`](https://github.com/phip1611/simple-chunk-allocator)
68
+
crate. It focuses on being a very simple-to-use general purpose allocator that "just works" for various workloads
69
+
in `no_std` context. However, there are other allocators, such as [`rust-osdev/linked-list-allocator`](https://github.com/rust-osdev/linked-list-allocator).
70
+
When you choose an allocator, you should not only consider the API and how to set it up, but actually the runtime
71
+
characteristics. OS research has shown us that there is no perfect allocator. You can optimize an allocator for speed,
72
+
memory utilization (i.e., prevent fragmentation), code simplicity, and worst case execution time. There exist different
73
+
strategies to reach those goals: first-fit, next-fit, best-fit
74
+
75
+
Recently, Philipp benchmarked his `simple-chunk-allocator` against [`rust-osdev/linked-list-allocator`](https://github.com/rust-osdev/linked-list-allocator)
76
+
to learn under which conditions which performs better. But at first, let's point out some differences. `simple-chunk-allocator` needs
77
+
a static backing storage for heap and an additional static backing storage for its internal bookkeeping. `linked-list-allocator`
78
+
can solve this better by organizing the heap with the heap backing memory itself. `simple-chunk-allocator` uses a slightly
79
+
adjusted variant of best-fit that tries to reduce fragmentation. `linked-list-allocator` is a first-fit allocator that
80
+
has a lower performance to more heap is used.
81
+
82
+
The relevant outcome is that `simple-chunk-allocator` always outperforms `linked-list-allocator` in median allocation time.
83
+
For stress tests with a low heap consumption, thus, no long stress test with 90% and more heap usage, `simple-chunk-allocator`
84
+
also outperforms `linked-list-allocator` in average allocation time. However, if the heap is full and frequent allocations
85
+
happen, the average (but not the median) allocation time of `linked-list-allocator` is better. Also, `linked-list-allocator`
86
+
can come close to 100% heap usage which is not the case for `simple-chunk-allocator`, because it suffers from internal
87
+
fragmentation under certain circumstances. Last but not least, even small allocations always takes up a multiple of the
88
+
used chunk size in `simple-chunk-allocator`.
89
+
90
+
In the end, there is no optimal allocator. You must choose which properties are more relevant for your scenario.
91
+
For concrete measurements, please head to the README of [`simple-chunk-allocator`](https://github.com/phip1611/simple-chunk-allocator).
0 commit comments