[libc-commits] [libc] [libc] Implement dual freestore rotation for baremetal heap (PR #209811)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Fri Aug 14 13:49:16 PDT 2026
SchrodingerZhu wrote:
# Performance Impact
## 1. Overview & Configuration Matrix
This report evaluates the throughput, latency distribution, real-world evaluation performance, and peak memory utilization efficiency of the dual FreeStore rotation mechanism (`LIBC_COPT_BAREMETAL_HEAP_ENABLE_FREESTORE_ROTATION`) and hardening mode (`LIBC_HARDENING_MODE`) in LLVM libc's `FreeListHeap`.
### Configuration Legend
- **`L822` (Baseline)**: Standard TLSF FreeStore without rotation or hardening.
- **`L82H` (Hardened)**: Baseline + Hardening enabled (`LIBC_COPT_HARDENING_MODE`).
- **`L82R` (Rotated)**: Dual FreeStore rotation enabled (`LIBC_COPT_BAREMETAL_HEAP_ENABLE_FREESTORE_ROTATION`).
- **`L8RH` (Rotated + Hardened)**: Dual FreeStore rotation + Hardening enabled.
---
## 2. Normalization by Evaluation (NBE Closure Evaluator)
*Evaluating 100 terms over 15 iterations involving heavy closure allocation, environment manipulation, and intermediate term destruction.*
| Configuration | Evaluation Rate (runs/s) | Result Value | Duration (Total) | Throughput Delta vs Baseline |
| :--- | :---: | :---: | :---: | :---: |
| **L822 (Baseline)** | **411 runs/s** | 1500 (Correct) | 36.44 ms | Baseline (100.0%) |
| **L82H (Hardened)** | **382 runs/s** | 1500 (Correct) | 39.20 ms | **-7.1%** |
| **L82R (Rotated)** | **337 runs/s** | 1500 (Correct) | 44.50 ms | **-18.0%** |
| **L8RH (Rot + Hard)** | **312 runs/s** | 1500 (Correct) | 47.98 ms | **-24.1%** |
---
## 3. Heap Efficiency (Peak Utilization)
*Peak memory utilization percentage achieved before heap exhaustion (evaluated across 50 rounds).*
| Configuration | Peak Utilization (%) | Efficiency Delta vs Baseline |
| :--- | :---: | :---: |
| **L822 (Baseline)** | **88.62%** | Baseline (0.0 pp) |
| **L82H (Hardened)** | **88.62%** | **0.0 pp (Identical)** |
| **L82R (Rotated)** | **79.88%** | **-8.74 pp** |
| **L8RH (Rot + Hard)** | **79.88%** | **-8.74 pp** |
---
## 4. Latency Quartiles (Alloc + Dealloc)
*Latency distributions in nanoseconds (ns) for combined Allocation + Deallocation operations across percentiles (p01, p25, p50, p75, p99).*
### 4.1 Mixture Workload
| Percentile | L822 (Baseline) | L82H (Hardened) | L82R (Rotated) | L8RH (Rot + Hard) |
| :--- | :---: | :---: | :---: | :---: |
| **p01 (Min/Fast-path)** | 2,503 ns | 2,593 ns | 3,006 ns | 3,202 ns |
| **p25** | 2,511 ns | 2,691 ns | 3,074 ns | 8,481 ns |
| **p50 (Median)** | **2,556 ns** | **2,736 ns** | **4,893 ns** | **10,916 ns** |
| **p75** | 3,819 ns | 4,375 ns | 5,330 ns | 12,999 ns |
| **p99 (Tail)** | 4,420 ns | 5,112 ns | 5,954 ns | 17,540 ns |
### 4.2 32B (Gaussian Distribution)
| Percentile | L822 (Baseline) | L82H (Hardened) | L82R (Rotated) | L8RH (Rot + Hard) |
| :--- | :---: | :---: | :---: | :---: |
| **p01** | 2,503 ns | 2,593 ns | 3,006 ns | 4,029 ns |
| **p25** | 2,511 ns | 2,691 ns | 4,683 ns | 12,135 ns |
| **p50 (Median)** | **2,511 ns** | **2,691 ns** | **5,157 ns** | **14,112 ns** |
| **p75** | 2,518 ns | 2,699 ns | 5,292 ns | 16,300 ns |
| **p99** | 3,984 ns | 4,465 ns | 5,886 ns | 19,954 ns |
### 4.3 160B (Gaussian Distribution)
| Percentile | L822 (Baseline) | L82H (Hardened) | L82R (Rotated) | L8RH (Rot + Hard) |
| :--- | :---: | :---: | :---: | :---: |
| **p01** | 2,503 ns | 2,593 ns | 3,006 ns | 4,029 ns |
| **p25** | 3,285 ns | 3,556 ns | 4,653 ns | 9,322 ns |
| **p50 (Median)** | **3,819 ns** | **4,352 ns** | **4,871 ns** | **11,999 ns** |
| **p75** | 3,954 ns | 4,525 ns | 5,300 ns | 13,239 ns |
| **p99** | 4,465 ns | 5,180 ns | 5,976 ns | 18,849 ns |
### 4.4 256B (Gaussian Distribution)
| Percentile | L822 (Baseline) | L82H (Hardened) | L82R (Rotated) | L8RH (Rot + Hard) |
| :--- | :---: | :---: | :---: | :---: |
| **p01** | 2,548 ns | 2,638 ns | 3,059 ns | 8,863 ns |
| **p25** | 3,811 ns | 4,322 ns | 4,736 ns | 11,555 ns |
| **p50 (Median)** | **3,857 ns** | **4,420 ns** | **4,916 ns** | **13,277 ns** |
| **p75** | 3,954 ns | 4,525 ns | 5,375 ns | 14,548 ns |
| **p99** | 4,465 ns | 5,180 ns | 5,976 ns | 19,789 ns |
---
## 5. Synthetic Throughput Benchmarks
### 5.1 Random Actions (No Realloc)
*Operations per second under Gaussian size distributions and a mixture profile.*
| Workload Distribution | L822 (Baseline) | L82H (Hardened) | L82R (Rotated) | L8RH (Rot + Hard) | Rotation Delta (L82R vs L822) | Hardening Delta (L82H vs L822) | Combined Delta (L8RH vs L822) |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **32B (Gaussian)** | 435.08 kOps/s | 411.92 kOps/s | 298.35 kOps/s | 282.76 kOps/s | **-31.4%** | -5.3% | -35.0% |
| **160B (Gaussian)** | 368.92 kOps/s | 336.29 kOps/s | 277.63 kOps/s | 261.20 kOps/s | **-24.8%** | -8.8% | -29.2% |
| **256B (Gaussian)** | 355.13 kOps/s | 321.13 kOps/s | 263.30 kOps/s | 246.63 kOps/s | **-25.9%** | -9.6% | -30.6% |
| **Mixture** | 384.16 kOps/s | 349.55 kOps/s | 299.44 kOps/s | 284.11 kOps/s | **-22.1%** | -9.0% | -26.0% |
---
### 5.2 Random Actions (With Realloc)
*Operations per second including in-place and relocating reallocations.*
| Workload Distribution | L822 (Baseline) | L82H (Hardened) | L82R (Rotated) | L8RH (Rot + Hard) | Rotation Delta (L82R vs L822) | Hardening Delta (L82H vs L822) | Combined Delta (L8RH vs L822) |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **32B (Gaussian)** | 335.72 kOps/s | 316.55 kOps/s | 259.45 kOps/s | 237.85 kOps/s | **-22.7%** | -5.7% | -29.2% |
| **160B (Gaussian)** | 275.30 kOps/s | 252.32 kOps/s | 110.35 kOps/s | 109.91 kOps/s | **-59.9%** | -8.3% | -60.1% |
| **256B (Gaussian)** | 257.73 kOps/s | 236.34 kOps/s | 177.01 kOps/s | 164.54 kOps/s | **-31.3%** | -8.3% | -36.2% |
| **Mixture** | 284.72 kOps/s | 263.92 kOps/s | 221.38 kOps/s | 208.32 kOps/s | **-22.2%** | -7.3% | -26.8% |
https://github.com/llvm/llvm-project/pull/209811
More information about the libc-commits
mailing list