Skip to content

Commit

Permalink
counters display, improved random actions, added frusa and rlsf
Browse files Browse the repository at this point in the history
  • Loading branch information
SFBdragon committed Mar 1, 2024
1 parent deb93cf commit 4b4069f
Show file tree
Hide file tree
Showing 17 changed files with 383 additions and 335 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "talc"
version = "4.2.0"
version = "4.3.0"
rust-version = "1.67.1"
edition = "2021"
readme = "README.md"
Expand Down Expand Up @@ -37,7 +37,9 @@ spin = { version = "0.9.8", default-features = false, features = ["lock_api", "s
linked_list_allocator = { version = "0.10", features = ["use_spin_nightly", "const_mut_refs", "alloc_ref"] }
good_memory_allocator = { version = "0.1", features = ["spin", "allocator"] }
buddy-alloc = "0.5"
dlmalloc = { version = "0.2.4", default-features = false, features = ["global"] }
dlmalloc = { version = "0.2.4", default-features = false, features = ["global"] }
frusa = "0.1.2"
rlsf = "0.2.1"

[profile.release]
lto = true
Expand Down
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<sep>

<sub><i>If you'd like to support my work, a tip would be greatly appreciated via [Paypal](https://www.paypal.com/donate/?hosted_button_id=8CSQ92VV58VPQ). Thanks!</i></sub>
<sub><i>If you find Talc useful, please consider leaving tip via [Paypal](https://www.paypal.com/donate/?hosted_button_id=8CSQ92VV58VPQ).</i></sub>

#### What is this for?
- Embedded systems, OS kernels, and other `no_std` environments
Expand Down Expand Up @@ -34,6 +34,7 @@ Targeting WebAssembly? You can find WASM-specific usage and benchmarks [here](./
- [Conditional Features](#conditional-features)
- [Stable Rust and MSRV](#stable-rust-and-msrv)
- [Algorithm](#algorithm)
- [Future Development](#future-development-v5)
- [Changelog](#changelog)


Expand Down Expand Up @@ -86,29 +87,29 @@ The average occupied capacity upon first allocation failure when randomly alloca

| Allocator | Average Random Actions Heap Efficiency |
| --------------------- | -------------------------------------- |
| dlmalloc | 99.07% |
| **talc** | 98.87% |
| linked_list_allocator | 98.28% |
| galloc | 95.86% |
| buddy_alloc | 58.75% |
| Dlmalloc | 99.14% |
| Rlsf | 99.06% |
| Talc | 98.97% |
| Linked List | 98.36% |
| Buddy Alloc | **63.14%** |

### Random Actions Benchmark

The number of successful allocations, deallocations, and reallocations within the allotted time.

#### Single Threaded
#### 1 Thread

![Random Actions Benchmark Results](/benchmark_graphs/random_actions.png)

#### 4 Threads, Increased Allocation Sizes
#### 4 Threads

![Random Actions Multi Benchmark Results](/benchmark_graphs/random_actions_multi.png)

## Allocations & Deallocations Microbenchmark

![Microbenchmark Results](/benchmark_graphs/microbench.png)

Whiskers represent the interval from the 5th to 95th percentile.
Label indicates the maximum within 50 standard deviations from the median. Max allocation size is 0x10000.

## General Usage

Expand Down Expand Up @@ -203,8 +204,23 @@ This is a dlmalloc-style linked list allocator with boundary tagging and bucketi

Additionally, the layout of chunk metadata is rearranged to allow for smaller minimum-size chunks to reduce memory overhead of small allocations. The minimum chunk size is `3 * usize`, with a single `usize` being reserved per allocation. This is more efficient than `dlmalloc` and `galloc`, despite using a similar algorithm.

## Future Development
- Support better concurrency, as it's the main deficit of the allocator
- Change the default features to be stable by default
- Add out-of-the-box support for more systems
- Allow for integrating with a backing allocator & (deferred) freeing of unused memory (e.g. better integration with mmap/paging)

## Changelog

#### v4.3.0

- Added an implementation for `Display` for the counters. Hopefully this makes your logs a bit prettier.
- Bug me if you have opinions about the current layout, I'm open to changing it.

- Added Frusa and RLSF to the benchmarks.
- Good showing by RLSF all around, and Frusa has particular workloads it excels at.
- Changed random actions benchmark to measure over various allocation sizes.

#### v4.2.0

- Optimized reallocation to allows other allocation operations to occur while memcopy-ing if an in-place reallocation failed.
Expand Down
22 changes: 12 additions & 10 deletions README_WASM.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,26 @@ static ALLOCATOR: talc::Talck<talc::locking::AssumeUnlockable, talc::ClaimOnOom>
Rough measurements of allocator size for relative comparison using `/wasm-size`.

| Allocator | WASM Size/bytes |
| --------- | ----- |
| lol_alloc | 11662 |
| **talc** (arena\*) | 13546 |
| **talc** | 14470 |
| dlmalloc (default) | 16079 |
| --------- | --------------- |
| lol_alloc | 11655 |
| rlsf | 12242 |
| **talc** (arena\*) | 13543 |
| **talc** | 14467 |
| dlmalloc (default) | 16767 |

\* uses a static arena instead of dynamically managing the heap

## WASM Benchmarks

Rough measurements of allocator speed for relative comparison using `/wasm-bench`.

| Allocator | Average Actions/s |
|-----------|-----|
| Allocator | Average Actions/us |
|-----------|--------------------|
| **talc** | 6.3 |
| **talc** (arena\*) | 6.2 |
| dlmalloc (default) | 5.8 |
| lol_alloc | 2.9 |
| **talc** (arena\*) | 6.3 |
| rlsf | 5.7 |
| dlmalloc (default) | 5.9 |
| lol_alloc | 4.1 |

\* uses a static arena instead of dynamically managing the heap

Expand Down
Binary file modified benchmark_graphs/microbench.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified benchmark_graphs/random_actions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified benchmark_graphs/random_actions_multi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4b4069f

Please sign in to comment.