diff --git a/CMakeLists.txt b/CMakeLists.txt index 82574287a..060b08b8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ option(MI_BUILD_OBJECT "Build object library" ON) option(MI_BUILD_TESTS "Build test executables" ON) option(MI_SKIP_COLLECT_ON_EXIT "Skip collecting memory on program exit" OFF) +option(MI_SINGLE_THREADED "Specialize for single-threaded use (removes the per-free thread-ownership check; unsafe with multiple threads)" OFF) option(MI_NO_PADDING "Force no use of padding even in DEBUG mode etc." OFF) option(MI_INSTALL_TOPLEVEL "Install directly into $CMAKE_INSTALL_PREFIX instead of PREFIX/lib/mimalloc-version" OFF) option(MI_NO_THP "Disable transparent huge pages support on Linux/Android for the mimalloc process only" OFF) @@ -301,6 +302,11 @@ if (MI_SKIP_COLLECT_ON_EXIT) list(APPEND mi_defines MI_SKIP_COLLECT_ON_EXIT=1) endif() +if (MI_SINGLE_THREADED) + message(STATUS "Specialize for single-threaded use (MI_SINGLE_THREADED=ON)") + list(APPEND mi_defines MI_SINGLE_THREADED=1) +endif() + if(MI_DEBUG_FULL) message(STATUS "Set debug level to full assertion and internal invariant checking (MI_DEBUG_FULL=ON, expensive)") set(MI_DEBUG ON) diff --git a/bench/single-threaded/README.md b/bench/single-threaded/README.md new file mode 100644 index 000000000..207f3ecbe --- /dev/null +++ b/bench/single-threaded/README.md @@ -0,0 +1,64 @@ +# `MI_SINGLE_THREADED` — analysis & reproduction + +This directory contains the full investigation behind the opt-in +`MI_SINGLE_THREADED` specialization of the free fast path, plus everything +needed to reproduce it. It documents **two** analyses: + +1. **Delivered change** — an idiomatic, safe `MI_SINGLE_THREADED` switch that + removes the per-free thread-ownership check. It gives a **statistically + significant 3.5–4.6 % cycle reduction** on allocator-bound single-threaded + workloads, and is a no-op for the default (multi-threaded) build. +2. **Rejected experiment** — an ExGen-Malloc-style *single free list* (push + frees straight onto `page->free` for immediate hot-block reuse). It is + correct and reduces L1 misses, but **regresses 4–4.5 %** because it destroys + the instruction-level parallelism that mimalloc's `free`/`local_free` split + provides. Kept on the `single-threaded-sota` branch as a documented negative + result. + +See [`REPORT.md`](REPORT.md) for the full write-up with numbers, counters and +methodology. + +## Layout + +``` +bench/single-threaded/ + REPORT.md full analysis (both parts) + microbench/ + churn.cpp allocator-bound micro: pure-LIFO + windowed reuse + reuse.c shows whether freed blocks are reused immediately + scripts/ + build_variants.sh build baseline + MI_SINGLE_THREADED=ON + run_micro.sh interleaved, pinned, perf-counter micro sweep + analyze_micro.py p50/p90/p99 + Mann-Whitney U + bootstrap CI + results/ reference data from an AMD EPYC 7742 run +``` + +## Quick reproduce + +```bash +# 1. build baseline + single-threaded variants (Release) +bench/single-threaded/scripts/build_variants.sh /tmp/mi-st + +# 2. pick the produced .so names (version suffix varies) +BASE=$(ls /tmp/mi-st/baseline/libmimalloc.so.*.* | grep -E '\.[0-9]+$' | head -1) +SINGLE=$(ls /tmp/mi-st/single/libmimalloc.so.*.* | grep -E '\.[0-9]+$' | head -1) + +# 3. interleaved, pinned sweep (set CORE to an isolated core; performance governor recommended) +CORE=4 REPEATS=21 OUT=micro.csv \ + bench/single-threaded/scripts/run_micro.sh "$BASE" baseline "$SINGLE" single + +# 4. stats +bench/single-threaded/scripts/analyze_micro.py micro.csv --baseline baseline +``` + +To reproduce the **rejected** single-list experiment, `git checkout +single-threaded-sota`, rebuild `single`, and add it as a third variant. + +## Notes on methodology + +* Pin to one isolated core (`taskset -c `); set the governor to + `performance` and warm the core before measuring (the runner does a 2 s warm-up). +* Measurements are **interleaved** (baseline/variant alternate every run) so + slow frequency/thermal drift cancels out. +* We report **cycles** (and IPC) from `perf`, not wall-clock alone, and never + rely on instruction count as a proxy for speed (see `REPORT.md`, §3). diff --git a/bench/single-threaded/REPORT.md b/bench/single-threaded/REPORT.md new file mode 100644 index 000000000..86339b9ff --- /dev/null +++ b/bench/single-threaded/REPORT.md @@ -0,0 +1,167 @@ +# Single-threaded specialization of mimalloc — full analysis + +**Hardware:** AMD EPYC 7742 (Zen 2, 64C/128T, 1 NUMA node), `performance` +governor, single pinned core, interleaved runs. +**Toolchain:** gcc 13.3, `-O3` Release, mimalloc `dev` @ `92854277`. +**Stats:** medians with p90/p99, Mann-Whitney U, 95 % bootstrap CI on the +median delta. All raw samples are in [`results/`](results/). + +--- + +## 0. The change + +In `mi_free_ex` (`src/free.c`) the free fast path performs a thread-ownership +test on every free: + +```c +const bool is_local = (_mi_prim_thread_id() == mi_atomic_load_relaxed(&segment->thread_id)); +``` + +If the program only ever calls mimalloc from one thread, every block is +thread-local and that test is redundant. `MI_SINGLE_THREADED` forces +`is_local = true` and (in debug builds) asserts the invariant instead: + +```c +#if MI_SINGLE_THREADED + mi_assert(_mi_prim_thread_id() == mi_atomic_load_relaxed(&segment->thread_id)); + const bool is_local = true; +#else + const bool is_local = (_mi_prim_thread_id() == mi_atomic_load_relaxed(&segment->thread_id)); +#endif +``` + +This is wired as a documented default in `include/mimalloc/types.h` +(`#if !defined(MI_SINGLE_THREADED) #define MI_SINGLE_THREADED 0`) and a CMake +option (`-DMI_SINGLE_THREADED=ON`), matching the existing `MI_*` switches. The +default build is byte-identical to baseline. + +### Safety + +The flag is a single-thread-only contract. With it on, calling mimalloc from +more than one thread is undefined. Unlike a bare branch removal, the debug build +keeps the ownership check as `mi_assert` (active from `MI_DEBUG>=1`, i.e. any +debug build including `-DMI_DEBUG=ON`), so multithreaded misuse aborts +immediately (verified: `test-stress` trips it at `free.c` with SIGABRT) instead +of silently corrupting the heap. Zero cost in release. + +--- + +## 1. Codegen verification + +`objdump` of `mi_ufree` (which inlines `mi_free_ex`): + +| build | instructions | `%fs:0x0` reads | mt branch | +|---|---|---|---| +| baseline | 48 | yes | `jne mi_free_generic_mt` | +| `MI_SINGLE_THREADED` | 41 | **none** | gone | + +The TLS read, the relaxed atomic load of `segment->thread_id`, the compare and +the `mt` branch are all removed. Output of `cfrac`/`espresso` is byte-identical. + +--- + +## 2. Why the gain depends on the workload + +The eliminated branch is **loop-invariant and always true**, so the hardware +predicts it perfectly: removing it does **not** change branch-miss counts. Its +only value is fewer *instructions*, which helps only when the allocator fast +path is actually on the critical path. + +`perf` branch-miss attribution on `alloc-test 1` (a common allocator benchmark): + +| where | share of branch-misses | +|---|---| +| **the benchmark's own RNG** (`randomPos_RandomSize<…>`) | **78.5 %** | +| libmimalloc (spread across alloc/free thunks) | 17.0 % | +| libc | 4.2 % | + +So on `alloc-test`/`sh6bench` most cycles are *not* in the allocator, and the +few saved instructions are hidden. That is why the original PR's wall-clock +claims did not reproduce here — and on `sh6bench` the change even regressed ++3.7 % from a **code-layout** artifact (instructions −4.4 %, but cycles +3.4 %, +IPC −7.5 %; the regression vanishes under PGO). Instruction count is not a +proxy for speed on an out-of-order core. + +(Real-benchmark sweep, n=51, is in `results/real_benchmarks_n51.csv`.) + +--- + +## 3. Where the gain is real — allocator-bound microbenchmarks + +`microbench/churn.cpp` keeps the harness work minimal so the allocator fast +path *is* the hot loop (pure LIFO, and windowed reuse of N live objects). + +**Cycles, baseline vs `MI_SINGLE_THREADED` (`single`), n=21, interleaved:** + +| workload | Δ cycles | IPC | Mann-Whitney p | 95 % CI | +|---|---|---|---|---| +| pure LIFO churn | **−4.61 %** | 2.98 → 3.04 | 2.4e-3 | excludes 0 | +| windowed, 4 K live | **−4.15 %** | flat | 4.4e-6 | excludes 0 | +| windowed, 64 K live | **−3.45 %** | flat | 2.9e-8 | excludes 0 | + +A genuine, significant **3.5–4.6 %** when the allocator is the bottleneck, with +IPC neutral-to-better (the saving converts cleanly). Reproduce with +`scripts/run_micro.sh` + `scripts/analyze_micro.py`; reference data in +`results/microbench_base_pron_sota_n21.csv`. + +--- + +## 4. Rejected experiment — ExGen-style single free list + +Motivated by *"Old is Gold: Optimizing Single-threaded Applications with +ExGen-Malloc"* (Li, John, Yadwadkar, IEEE CAL 2025, arXiv:2510.10219), which +uses a single free-block list. mimalloc instead splits `free` (malloc pops) from +`local_free` (free pushes), reconciling them in `_mi_page_free_collect`. A +consequence (`microbench/reuse.c`): a freed block is **not** reused on the next +allocation — it stays in `local_free` until a migration, so it goes cold. + +On the `single-threaded-sota` branch, under `MI_SINGLE_THREADED` the free path +pushes directly onto `page->free` (clearing `free_is_zero` for calloc +correctness): + +```c +#if MI_SINGLE_THREADED + mi_block_set_next(page, block, page->free); + page->free = block; + page->free_is_zero = false; +#else + mi_block_set_next(page, block, page->local_free); + page->local_free = block; +#endif +``` + +* **Correct:** 43/43 api tests pass and heavy churn runs clean under + `MI_DEBUG_FULL`; `reuse.c` confirms immediate LIFO reuse. +* **Helps the metrics it targets:** L1-dcache-load-misses −6.7 %, instructions + −3.5 % on large-window churn. +* **But it regresses (cycles):** pure LIFO −3.7 % (worse than `single`'s + −4.6 %), windowed 4 K **+4.34 %**, windowed 64 K **+4.55 %** — all significant. + IPC drops 2.57 → 2.36. + +**Root cause.** mimalloc's `free`/`local_free` split is not only for +thread-safety: it decouples the pointer malloc reads (`page->free`) from the +pointer free writes (`page->local_free`), letting the out-of-order core overlap +alloc and free. Merging them serializes the chain (free's store to `page->free` +must retire before the next malloc's load), so IPC collapses and the change +loses despite fewer instructions and fewer cache misses. ExGen is a from-scratch +design without this property; porting just the list-merge into mimalloc +backfires. **Rejected.** + +Reference data: `results/microbench_base_pron_sota_n21.csv` (the `sota` column). + +--- + +## 5. Conclusions + +* `MI_SINGLE_THREADED` (idiomatic + debug assert) is a safe, no-op-by-default + switch that delivers a real, significant **3.5–4.6 %** on allocator-bound + single-threaded workloads. Recommended to ship as such — **not** as a general + speedup, since workloads where the allocator isn't the bottleneck see ~0. +* On x86 the release fast path is already minimal (`MI_STAT=0`, security/debug + checks compile out), so the predicted-branch elimination is the realistic + ceiling for a *safe* single-thread fast-path specialization. +* The single-list idea, though SOTA-motivated, is the wrong port for mimalloc + and is rejected on evidence (ILP loss). +* Larger single-thread wins, if pursued, lie in ExGen's *other* lever — + memory-footprint / metadata compaction — validated against RSS and LLC/dTLB, + not instruction count. diff --git a/bench/single-threaded/microbench/churn.cpp b/bench/single-threaded/microbench/churn.cpp new file mode 100644 index 000000000..557b4f22b --- /dev/null +++ b/bench/single-threaded/microbench/churn.cpp @@ -0,0 +1,42 @@ +// Allocator-bound churn: tight alloc/free with minimal harness work. +// Mode A: pure LIFO reuse (alloc then immediately free) -> tests fast-path cycles. +// Mode B: windowed churn (keep N live, free oldest) -> tests temporal reuse / L1. +#include +#include +#include +#include +#include +int main(int argc, char** argv){ + int mode = argc>1? atoi(argv[1]) : 1; // 1=pure, 2=windowed + long iters = argc>2? atol(argv[2]) : 200000000L; + long winl = argc>3? atol(argv[3]) : 4096; // live objects in windowed mode + long szl = argc>4? atol(argv[4]) : 32; + // validate as signed so negatives don't wrap to a huge size_t + if((mode!=1 && mode!=2) || iters<=0 || szl<=0 || (mode==2 && winl<=0)){ + fprintf(stderr,"usage: churn 0)> [window(>0)] [size(>0)]\n"); + return 2; + } + size_t win = (size_t)winl; + size_t sz = (size_t)szl; + volatile uint64_t sink=0; // prevent the touch/read loop from being optimized away + if(mode==1){ + for(long i=0;i live(win,nullptr); + for(long i=0;i +#include +int main(){ + for(int i=0;i<5;i++){ + void* a=malloc(32); free(a); + void* b=malloc(32); free(b); + printf("a=%p b=%p same=%d\n",a,b,a==b); + } + // sequence: alloc two, free both, realloc two + void* x=malloc(32); void* y=malloc(32); + printf("x=%p y=%p\n",x,y); free(x); free(y); + void* z=malloc(32); void* w=malloc(32); + printf("z=%p w=%p z==y?%d z==x?%d\n",z,w,z==y,z==x); + return 0; +} diff --git a/bench/single-threaded/results/ipc_sh6bench_n11.csv b/bench/single-threaded/results/ipc_sh6bench_n11.csv new file mode 100644 index 000000000..7342da6f1 --- /dev/null +++ b/bench/single-threaded/results/ipc_sh6bench_n11.csv @@ -0,0 +1,23 @@ +bench,variant,cycles,instructions,task_ms +sh6bench1,base,5061863111,12601890942,1502.04 +sh6bench1,pron,5175116799,12051422378,1528.01 +sh6bench1,base,5007903932,12601463011,1478.61 +sh6bench1,pron,5173371947,12050799968,1542.45 +sh6bench1,base,4928619778,12602232778,1457.63 +sh6bench1,pron,5164915301,12050440414,1529.49 +sh6bench1,base,4966924959,12600941126,1477.39 +sh6bench1,pron,5208098391,12049742882,1539.60 +sh6bench1,base,5041147742,12601901927,1497.06 +sh6bench1,pron,5151798803,12051041328,1526.98 +sh6bench1,base,5088767504,12601758941,1503.23 +sh6bench1,pron,5157653849,12050574951,1524.38 +sh6bench1,base,5005914095,12601691389,1480.56 +sh6bench1,pron,5102136564,12049790174,1508.75 +sh6bench1,base,4995136342,12602410178,1476.02 +sh6bench1,pron,5198407042,12050575976,1535.47 +sh6bench1,base,5017657877,12600643466,1481.73 +sh6bench1,pron,5208681176,12050992263,1539.90 +sh6bench1,base,4969227458,12600994052,1476.35 +sh6bench1,pron,5184571231,12052025416,1546.24 +sh6bench1,base,4956722350,12603472176,1467.03 +sh6bench1,pron,5195855075,12050150961,1539.24 diff --git a/bench/single-threaded/results/microbench_base_pron_sota_n21.csv b/bench/single-threaded/results/microbench_base_pron_sota_n21.csv new file mode 100644 index 000000000..45ea83991 --- /dev/null +++ b/bench/single-threaded/results/microbench_base_pron_sota_n21.csv @@ -0,0 +1,190 @@ +mode,variant,cycles,instructions +1_100000000,base,4212221493,11598975511 +1_100000000,pron,4060848737,11298584047 +1_100000000,sota,4136405050,11316439892 +1_100000000,base,4190580549,11599193005 +1_100000000,pron,4199826896,11299272409 +1_100000000,sota,4104978278,11316630197 +1_100000000,base,4197478440,11599071481 +1_100000000,pron,4028505623,11297296112 +1_100000000,sota,4022568290,11316058426 +1_100000000,base,4134452750,11598699548 +1_100000000,pron,4083203417,11298592934 +1_100000000,sota,4073702514,11316255190 +1_100000000,base,4201775005,11599059049 +1_100000000,pron,4387870694,11298697435 +1_100000000,sota,4131334022,11316069121 +1_100000000,base,4156934405,11598714714 +1_100000000,pron,3964447869,11298196313 +1_100000000,sota,3751250870,11315380414 +1_100000000,base,3885828393,11598081598 +1_100000000,pron,3725815858,11297846978 +1_100000000,sota,3747409201,11315668425 +1_100000000,base,3898570798,11598366758 +1_100000000,pron,3712492331,11297711494 +1_100000000,sota,3740718959,11315394187 +1_100000000,base,3904070433,11598171800 +1_100000000,pron,3720230919,11297372604 +1_100000000,sota,3739533579,11314004699 +1_100000000,base,3899119152,11598034373 +1_100000000,pron,3709803725,11297206318 +1_100000000,sota,3737841752,11315416199 +1_100000000,base,3895171601,11598373905 +1_100000000,pron,3718743477,11297729457 +1_100000000,sota,3759757482,11315925422 +1_100000000,base,3892081216,11598389274 +1_100000000,pron,3715706165,11297832724 +1_100000000,sota,3737035673,11315267989 +1_100000000,base,3884835198,11598247750 +1_100000000,pron,3708414213,11297527816 +1_100000000,sota,3765444347,11315563204 +1_100000000,base,3883050146,11597326628 +1_100000000,pron,3711560359,11297389427 +1_100000000,sota,3751924138,11315388225 +1_100000000,base,3889481801,11598213287 +1_100000000,pron,3715332353,11297594384 +1_100000000,sota,3737469539,11314399726 +1_100000000,base,3899218598,11598300520 +1_100000000,pron,3709866577,11297472053 +1_100000000,sota,3744298756,11315427157 +1_100000000,base,3884575323,11598063036 +1_100000000,pron,3708391310,11297420188 +1_100000000,sota,3782568206,11315578089 +1_100000000,base,3894507447,11598179687 +1_100000000,pron,3717933167,11297612653 +1_100000000,sota,3772240525,11315534109 +1_100000000,base,3883849805,11598022997 +1_100000000,pron,3715244774,11297577715 +1_100000000,sota,3747594744,11315522419 +1_100000000,base,3883453579,11597458198 +1_100000000,pron,3709384029,11297330281 +1_100000000,sota,3750495050,11315804889 +1_100000000,base,3892419915,11598623555 +1_100000000,pron,3713028019,11297756538 +1_100000000,sota,3741927821,11314727167 +2_100000000_4096_32,base,2555670367,6467082337 +2_100000000_4096_32,pron,2440532996,6167196520 +2_100000000_4096_32,sota,2660206604,6241837025 +2_100000000_4096_32,base,2548228633,6467536412 +2_100000000_4096_32,pron,2443271845,6167142554 +2_100000000_4096_32,sota,2656717055,6241828238 +2_100000000_4096_32,base,2552649508,6467411479 +2_100000000_4096_32,pron,2439508223,6167135216 +2_100000000_4096_32,sota,2654811181,6241754234 +2_100000000_4096_32,base,2546676108,6467370550 +2_100000000_4096_32,pron,2442342882,6167044987 +2_100000000_4096_32,sota,2664836151,6241898627 +2_100000000_4096_32,base,2550933846,6467558789 +2_100000000_4096_32,pron,2634190245,6167779957 +2_100000000_4096_32,sota,2660903081,6241995442 +2_100000000_4096_32,base,2550933506,6467775740 +2_100000000_4096_32,pron,2441017341,6167384394 +2_100000000_4096_32,sota,2665232761,6242016663 +2_100000000_4096_32,base,2550756336,6467701100 +2_100000000_4096_32,pron,2443601390,6167343327 +2_100000000_4096_32,sota,2659959061,6242033884 +2_100000000_4096_32,base,2574827490,6471472753 +2_100000000_4096_32,pron,2445097342,6167218238 +2_100000000_4096_32,sota,2670994963,6241092136 +2_100000000_4096_32,base,2549399736,6467756144 +2_100000000_4096_32,pron,2437587438,6166282444 +2_100000000_4096_32,sota,3326939488,6244142146 +2_100000000_4096_32,base,2544619897,6467174105 +2_100000000_4096_32,pron,2473394959,6167459545 +2_100000000_4096_32,sota,2658210559,6241943194 +2_100000000_4096_32,base,2565397356,6467628301 +2_100000000_4096_32,pron,2445156998,6167357849 +2_100000000_4096_32,sota,2665280696,6242060773 +2_100000000_4096_32,base,2573639406,6467775523 +2_100000000_4096_32,pron,2443509133,6167225170 +2_100000000_4096_32,sota,2660997724,6241848073 +2_100000000_4096_32,base,2666349635,6467875250 +2_100000000_4096_32,pron,2464487332,6167398945 +2_100000000_4096_32,sota,2667064875,6242082837 +2_100000000_4096_32,base,2552069611,6467624928 +2_100000000_4096_32,pron,2456767126,6167344376 +2_100000000_4096_32,sota,2661681087,6241932867 +2_100000000_4096_32,base,2550600988,6467625866 +2_100000000_4096_32,pron,2445681742,6166359051 +2_100000000_4096_32,sota,2661576233,6241899827 +2_100000000_4096_32,base,2550045870,6467733632 +2_100000000_4096_32,pron,2463662286,6167383710 +2_100000000_4096_32,sota,2657226266,6241939251 +2_100000000_4096_32,base,2574896040,6467555894 +2_100000000_4096_32,pron,2458570642,6167470413 +2_100000000_4096_32,sota,3444613143,6244501899 +2_100000000_4096_32,base,2550118095,6467623029 +2_100000000_4096_32,pron,2626344278,6167878989 +2_100000000_4096_32,sota,2666099588,6241673834 +2_100000000_4096_32,base,2550006857,6467580047 +2_100000000_4096_32,pron,2449312731,6167306439 +2_100000000_4096_32,sota,2655840847,6241885692 +2_100000000_4096_32,base,2706303024,6468025845 +2_100000000_4096_32,pron,2438314030,6167209209 +2_100000000_4096_32,sota,2665344503,6241958376 +2_100000000_4096_32,base,2545751124,6467477472 +2_100000000_4096_32,pron,2531605863,6167442086 +2_100000000_4096_32,sota,2657428997,6241149718 +2_100000000_65536_32,base,2532174336,6466401155 +2_100000000_65536_32,pron,2439004326,6166228330 +2_100000000_65536_32,sota,2671385263,6241146150 +2_100000000_65536_32,base,2516856270,6466329198 +2_100000000_65536_32,pron,2454378830,6166295955 +2_100000000_65536_32,sota,2628562016,6241411263 +2_100000000_65536_32,base,2540814829,6466527941 +2_100000000_65536_32,pron,2424905084,6165751312 +2_100000000_65536_32,sota,2652136360,6241603066 +2_100000000_65536_32,base,2519214018,6466465856 +2_100000000_65536_32,pron,2432245879,6166231358 +2_100000000_65536_32,sota,2628040504,6241089081 +2_100000000_65536_32,base,2520294311,6466246402 +2_100000000_65536_32,pron,2428761023,6166089042 +2_100000000_65536_32,sota,2651159226,6241267751 +2_100000000_65536_32,base,2513950433,6466273808 +2_100000000_65536_32,pron,2428631626,6166104301 +2_100000000_65536_32,sota,2626834258,6241235982 +2_100000000_65536_32,base,2526702770,6466513365 +2_100000000_65536_32,pron,2433473751,6166329033 +2_100000000_65536_32,sota,2627954212,6241407553 +2_100000000_65536_32,base,2567196133,6466749346 +2_100000000_65536_32,pron,2426836193,6166281163 +2_100000000_65536_32,sota,2645106250,6241226104 +2_100000000_65536_32,base,2520775585,6466459334 +2_100000000_65536_32,pron,2440182868,6166279264 +2_100000000_65536_32,sota,2668944783,6240641174 +2_100000000_65536_32,base,2520851942,6465985395 +2_100000000_65536_32,pron,2433306915,6166179945 +2_100000000_65536_32,sota,2622231828,6241305857 +2_100000000_65536_32,base,2526555615,6466558289 +2_100000000_65536_32,pron,2468474095,6166487437 +2_100000000_65536_32,sota,2627167350,6241408407 +2_100000000_65536_32,base,2533503279,6466675510 +2_100000000_65536_32,pron,2447315470,6165319590 +2_100000000_65536_32,sota,2638146540,6241252760 +2_100000000_65536_32,base,2569908709,6466529346 +2_100000000_65536_32,pron,2488692076,6166490876 +2_100000000_65536_32,sota,2672540103,6241372693 +2_100000000_65536_32,base,2511804262,6466426884 +2_100000000_65536_32,pron,2434031572,6166076642 +2_100000000_65536_32,sota,2652749887,6241218609 +2_100000000_65536_32,base,2516272431,6466182740 +2_100000000_65536_32,pron,2434714844,6166219244 +2_100000000_65536_32,sota,2622552603,6241264667 +2_100000000_65536_32,base,2521833711,6466422268 +2_100000000_65536_32,pron,2435385101,6166210246 +2_100000000_65536_32,sota,2649725873,6241291916 +2_100000000_65536_32,base,2539482048,6466679418 +2_100000000_65536_32,pron,2463118294,6166352616 +2_100000000_65536_32,sota,2636572310,6241391621 +2_100000000_65536_32,base,2520802912,6466494950 +2_100000000_65536_32,pron,2430345614,6166169183 +2_100000000_65536_32,sota,2622034496,6240146125 +2_100000000_65536_32,base,2609218828,6466545052 +2_100000000_65536_32,pron,2451434752,6166310983 +2_100000000_65536_32,sota,2674854026,6241473956 +2_100000000_65536_32,base,2519126721,6466560547 +2_100000000_65536_32,pron,2431611217,6166153734 +2_100000000_65536_32,sota,2625358636,6241133903 +2_100000000_65536_32,base,2524090894,6466578636 +2_100000000_65536_32,pron,2457462629,6165697478 +2_100000000_65536_32,sota,2633097634,6241332099 diff --git a/bench/single-threaded/results/pgo_base_on_n21.csv b/bench/single-threaded/results/pgo_base_on_n21.csv new file mode 100644 index 000000000..6a4b58136 --- /dev/null +++ b/bench/single-threaded/results/pgo_base_on_n21.csv @@ -0,0 +1,85 @@ +bench,variant,internal,cycles,instructions +sh6bench1,base,1.5340,5202557165,12603466349 +alloc-test1,base,3451,11697125402,13021211270 +sh6bench1,on,1.5265,5181932086,12603858561 +alloc-test1,on,3440,11668283104,13020654178 +sh6bench1,base,1.5366,5218633117,12603016067 +alloc-test1,base,3435,11659387643,13020487802 +sh6bench1,on,1.5188,5159140518,12602827833 +alloc-test1,on,3445,11676791725,13021266095 +sh6bench1,base,1.5316,5187781952,12604197074 +alloc-test1,base,3439,11669045048,13021602820 +sh6bench1,on,1.5321,5195227371,12603927260 +alloc-test1,on,3437,11661266777,13020575418 +sh6bench1,base,1.5336,5205349663,12602981576 +alloc-test1,base,3437,11665742767,13021376644 +sh6bench1,on,1.5410,5233954661,12602326531 +alloc-test1,on,3452,11701830873,13021636470 +sh6bench1,base,1.5194,5155194826,12605325203 +alloc-test1,base,3443,11682554141,13021801543 +sh6bench1,on,1.5236,5173126418,12602983160 +alloc-test1,on,3436,11658571353,13020390310 +sh6bench1,base,1.5450,5241132444,12604333167 +alloc-test1,base,3443,11668361386,13020808842 +sh6bench1,on,1.5227,5160447403,12603194668 +alloc-test1,on,3440,11668684827,13020856865 +sh6bench1,base,1.5434,5226381445,12603120530 +alloc-test1,base,3448,11679882188,13021891710 +sh6bench1,on,1.5425,5229908357,12603683519 +alloc-test1,on,3437,11660498149,13020533238 +sh6bench1,base,1.5314,5200993261,12602785215 +alloc-test1,base,3442,11692642820,13021582043 +sh6bench1,on,1.5356,5216456197,12602843681 +alloc-test1,on,3444,11673837667,13021786991 +sh6bench1,base,1.5462,5241226434,12603719587 +alloc-test1,base,3442,11678632969,13020645959 +sh6bench1,on,1.5230,5172782637,12603209391 +alloc-test1,on,3436,11651823436,13020621158 +sh6bench1,base,1.5530,5276522632,12603498166 +alloc-test1,base,3433,11645946203,13020484531 +sh6bench1,on,1.5241,5175734386,12602280138 +alloc-test1,on,3432,11642311681,13021821862 +sh6bench1,base,1.5498,5262913781,12603664355 +alloc-test1,base,3442,11672563284,13020859979 +sh6bench1,on,1.5022,5103440545,12602272277 +alloc-test1,on,3439,11666382071,13021589633 +sh6bench1,base,1.5237,5173015845,12603996902 +alloc-test1,base,3481,11810157611,13023992388 +sh6bench1,on,1.5235,5169368329,12603940509 +alloc-test1,on,3477,11798564255,13022744178 +sh6bench1,base,1.5276,5181278928,12604481811 +alloc-test1,base,3442,11677027747,13021009583 +sh6bench1,on,1.5437,5231156090,12601716861 +alloc-test1,on,3446,11695165139,13020869450 +sh6bench1,base,1.5327,5202927982,12602172197 +alloc-test1,base,3438,11685684817,13021542386 +sh6bench1,on,1.5396,5227138260,12604268658 +alloc-test1,on,3447,11696037299,13024826546 +sh6bench1,base,1.5421,5231567515,12603842927 +alloc-test1,base,3466,11743338536,13021776977 +sh6bench1,on,1.5377,5221374647,12602956524 +alloc-test1,on,3446,11687364787,13021665740 +sh6bench1,base,1.5242,5175873857,12602847997 +alloc-test1,base,3432,11666494455,13021887036 +sh6bench1,on,1.5287,5195365687,12604429199 +alloc-test1,on,3434,11660941711,13020774001 +sh6bench1,base,1.5291,5182084042,12602988399 +alloc-test1,base,3448,11682256607,13021115106 +sh6bench1,on,1.5391,5223783656,12602949593 +alloc-test1,on,3435,11664873480,13020699013 +sh6bench1,base,1.5284,5190551215,12602794853 +alloc-test1,base,3444,11678672727,13021137706 +sh6bench1,on,1.5211,5165540762,12602902099 +alloc-test1,on,3449,11673903948,13022159170 +sh6bench1,base,1.5389,5223141106,12602247868 +alloc-test1,base,3450,11682043677,13021466722 +sh6bench1,on,1.5324,5197981043,12604070906 +alloc-test1,on,3442,11660481517,13020772124 +sh6bench1,base,1.5291,5189501809,12601080690 +alloc-test1,base,3431,11655138675,13020464319 +sh6bench1,on,1.5348,5214072341,12604103231 +alloc-test1,on,3432,11657720892,13021227861 +sh6bench1,base,1.5377,5206250690,12603747230 +alloc-test1,base,3452,11683695629,13021659431 +sh6bench1,on,1.5371,5215684237,12604284031 +alloc-test1,on,3443,11677914746,13021184173 diff --git a/bench/single-threaded/results/real_benchmarks_n51.csv b/bench/single-threaded/results/real_benchmarks_n51.csv new file mode 100644 index 000000000..0b358961c --- /dev/null +++ b/bench/single-threaded/results/real_benchmarks_n51.csv @@ -0,0 +1,409 @@ +bench,variant,run,task_clock_ms,instructions,branches,branch_misses,internal +alloc-test1,base,1,3521.73,13028109370,2075484061,263977494,3519 +alloc-test1,pron,1,3474.02,12875464080,2024744757,263382655,3472 +alloc-test1,base,2,3463.40,13025701666,2074839066,263348635,3462 +alloc-test1,pron,2,3492.42,12876647978,2024967739,263391688,3491 +alloc-test1,base,3,3485.74,13026335308,2074951030,263422201,3484 +alloc-test1,pron,3,3480.80,12875453969,2024739681,263390086,3480 +alloc-test1,base,4,3468.80,13025007002,2074697045,263363325,3467 +alloc-test1,pron,4,3475.38,12874906798,2024633735,263419729,3474 +alloc-test1,base,5,3487.60,13026151410,2074921361,263309176,3486 +alloc-test1,pron,5,3484.64,12874899704,2024621432,263415546,3484 +alloc-test1,base,6,3477.81,13025824194,2074846555,263467201,3476 +alloc-test1,pron,6,3485.01,12874362133,2024507192,263303870,3483 +alloc-test1,base,7,3448.57,13024034233,2074507426,263437917,3447 +alloc-test1,pron,7,3475.71,12876991537,2025316595,263320954,3474 +alloc-test1,base,8,3462.53,13024794665,2074647520,263288581,3462 +alloc-test1,pron,8,3498.52,12875481645,2024730433,263391737,3497 +alloc-test1,base,9,3436.16,13024600519,2074625156,263393135,3435 +alloc-test1,pron,9,3481.61,12874297878,2024493125,263333955,3480 +alloc-test1,base,10,3464.38,13024539627,2074606569,263356137,3463 +alloc-test1,pron,10,3483.78,12873648491,2024370286,263354335,3482 +alloc-test1,base,11,3444.61,13024199742,2074540340,263223793,3443 +alloc-test1,pron,11,3469.44,12874709594,2024587695,263275351,3468 +alloc-test1,base,12,3490.68,13025305858,2074740465,263322459,3489 +alloc-test1,pron,12,3472.03,12873721411,2024388489,263347603,3471 +alloc-test1,base,13,3474.50,13024823360,2074643352,263401082,3473 +alloc-test1,pron,13,3492.37,12875707961,2024785472,263459235,3491 +alloc-test1,base,14,3527.71,13026258376,2074942517,263401258,3527 +alloc-test1,pron,14,3516.39,12875964622,2024832051,263386236,3515 +alloc-test1,base,15,3475.40,13024450280,2074580165,263407094,3474 +alloc-test1,pron,15,3511.51,12875316279,2024705130,263423073,3510 +alloc-test1,base,16,3478.52,13025394031,2074763336,263557297,3477 +alloc-test1,pron,16,3476.40,12874683556,2024584155,263419141,3475 +alloc-test1,base,17,3606.30,13026272537,2074936570,263875396,3605 +alloc-test1,pron,17,3602.77,12875190083,2024674780,263846662,3602 +alloc-test1,base,18,3468.03,13024400053,2074574751,263377808,3467 +alloc-test1,pron,18,3488.30,12874609129,2024570137,263311555,3487 +alloc-test1,base,19,3462.08,13024378976,2074570284,263361785,3460 +alloc-test1,pron,19,3459.71,12873327530,2024324643,263410995,3459 +alloc-test1,base,20,3430.96,13024312604,2074570918,263205672,3429 +alloc-test1,pron,20,3465.33,12873787102,2024400892,263204425,3464 +alloc-test1,base,21,3433.13,13023805238,2074471221,263282606,3432 +alloc-test1,pron,21,3621.96,12878182669,2025237685,263633387,3621 +alloc-test1,base,22,3460.40,13024115341,2074519225,263334438,3459 +alloc-test1,pron,22,3485.76,12874571578,2024567164,263224391,3484 +alloc-test1,base,23,3511.25,13024783208,2074646432,263420745,3509 +alloc-test1,pron,23,3466.19,12874880337,2024624396,263388269,3465 +alloc-test1,base,24,3423.44,13024741975,2074658634,263189745,3422 +alloc-test1,pron,24,3452.48,12873861058,2024413643,263373988,3450 +alloc-test1,base,25,3431.45,13024661380,2074627793,263377439,3430 +alloc-test1,pron,25,3509.56,12874887352,2024620216,263423979,3508 +alloc-test1,base,26,3522.74,13026730656,2075052889,263534734,3912 +alloc-test1,pron,26,3532.55,12876884910,2025036040,263753743,4579 +alloc-test1,base,27,3442.38,13023974806,2074501455,263310847,3442 +alloc-test1,pron,27,3458.40,12874296896,2024498128,263329422,3457 +alloc-test1,base,28,3445.46,13025825019,2074872568,263304468,3444 +alloc-test1,pron,28,3461.74,12875313782,2024901277,263232088,3460 +alloc-test1,base,29,3435.69,13025036985,2074717534,263248958,3434 +alloc-test1,pron,29,3456.99,12873805745,2024411707,263345634,3456 +alloc-test1,base,30,3416.09,13023353939,2074376368,263180394,3415 +alloc-test1,pron,30,3457.74,12874491292,2024560134,263427645,3457 +alloc-test1,base,31,3435.20,13024160165,2074546797,263390806,3434 +alloc-test1,pron,31,3487.07,12873937988,2024438459,263419310,3485 +alloc-test1,base,32,3451.44,13025182679,2074717029,263386177,3451 +alloc-test1,pron,32,3450.60,12874929810,2024625895,263251863,3449 +alloc-test1,base,33,3420.59,13023883655,2074479679,263270978,3419 +alloc-test1,pron,33,3463.05,12873066185,2024270875,263320260,3462 +alloc-test1,base,34,3448.03,13023620713,2074429969,263529346,3447 +alloc-test1,pron,34,3459.80,12872685020,2024196364,263283246,3458 +alloc-test1,base,35,3429.72,13022996691,2074300620,263229179,3429 +alloc-test1,pron,35,3466.06,12874194962,2024490915,263215351,3465 +alloc-test1,base,36,3449.27,13023721662,2074450788,263381388,3448 +alloc-test1,pron,36,3512.20,12873488189,2024344966,263512781,3511 +alloc-test1,base,37,3603.38,13026089241,2074891839,263786429,3602 +alloc-test1,pron,37,3456.02,12874081951,2024467324,263208269,3455 +alloc-test1,base,38,3450.38,13023688214,2074436415,263259057,3449 +alloc-test1,pron,38,3463.86,12872649226,2024187256,263301344,3462 +alloc-test1,base,39,3423.42,13023662408,2074444700,263158096,3422 +alloc-test1,pron,39,3445.42,12872588391,2024176942,263237236,3444 +alloc-test1,base,40,3433.48,13023914395,2074502174,263280699,3432 +alloc-test1,pron,40,3462.09,12872836866,2024228558,263421063,3461 +alloc-test1,base,41,3411.88,13022717184,2074261736,263251230,3411 +alloc-test1,pron,41,3441.31,12873323809,2024327119,263325413,3440 +alloc-test1,base,42,3428.33,13023067651,2074324031,263347327,3427 +alloc-test1,pron,42,3450.24,12872543360,2024165469,263325006,3449 +alloc-test1,base,43,3437.83,13022845726,2074280481,263238977,3436 +alloc-test1,pron,43,3438.40,12872350267,2024130392,263259367,3436 +alloc-test1,base,44,3438.16,13023168668,2074339893,263237147,3437 +alloc-test1,pron,44,3452.08,12873499178,2024361036,263236435,3451 +alloc-test1,base,45,3474.15,13023880290,2074478922,263384165,3472 +alloc-test1,pron,45,3458.82,12873047641,2024268599,263328832,3457 +alloc-test1,base,46,3425.82,13023949933,2074508440,263173983,3425 +alloc-test1,pron,46,3445.91,12873164789,2024294744,263295250,3445 +alloc-test1,base,47,3444.23,13024329460,2074583608,263212744,3442 +alloc-test1,pron,47,3452.68,12873321652,2024327444,263258746,3451 +alloc-test1,base,48,3448.67,13023161942,2074344091,263554491,3447 +alloc-test1,pron,48,3456.98,12872589368,2024180423,263367635,3455 +alloc-test1,base,49,3421.64,13023493355,2074414044,263129712,3420 +alloc-test1,pron,49,3450.77,12873263857,2024320929,263397072,3449 +alloc-test1,base,50,3421.81,13027162450,2075590902,263289065,3420 +alloc-test1,pron,50,3437.05,12872168820,2024092237,263255146,3435 +alloc-test1,base,51,3433.81,13023180528,2074348823,263243028,3433 +alloc-test1,pron,51,3446.90,12872850773,2024232795,263302610,3446 +cfrac,base,1,7375.60,44020659461,7052582150,34229556, +cfrac,pron,1,7391.95,43747274984,6961294607,34280311, +cfrac,base,2,7384.19,44021190622,7052674708,34049323, +cfrac,pron,2,7403.35,43747881043,6961387216,34181076, +cfrac,base,3,7401.60,44021770705,7052790576,34179950, +cfrac,pron,3,7531.90,43751221589,6962042777,34656525, +cfrac,base,4,7370.88,44020274678,7052498394,34036382, +cfrac,pron,4,7406.17,43747085094,6961247642,34122980, +cfrac,base,5,7372.88,44020155590,7052473848,34008252, +cfrac,pron,5,7368.68,43745906023,6961009888,34035638, +cfrac,base,6,7420.16,44021954941,7052828024,34114226, +cfrac,pron,6,7377.96,43746157035,6961062361,34045752, +cfrac,base,7,7406.22,44021348091,7052710363,34184151, +cfrac,pron,7,7374.54,43746267582,6961088324,34124421, +cfrac,base,8,7399.04,44021100040,7052661871,34072721, +cfrac,pron,8,7357.26,43745966362,6961023999,34014237, +cfrac,base,9,7373.68,44020604744,7052568948,33984642, +cfrac,pron,9,7338.88,43745231811,6960878748,34078991, +cfrac,base,10,7414.00,44023986725,7053431849,34170608, +cfrac,pron,10,7365.44,43746064890,6961031641,34086179, +cfrac,base,11,7411.16,44021652314,7052763709,34126983, +cfrac,pron,11,7377.12,43746535577,6961130882,33986618, +cfrac,base,12,7383.00,44021097650,7052651299,34073938, +cfrac,pron,12,7389.04,43747191220,6961243404,34071500, +cfrac,base,13,7393.48,44021744551,7052775709,34146356, +cfrac,pron,13,7419.59,43747631857,6961335404,34176109, +cfrac,base,14,7441.74,44022975636,7053009131,34126745, +cfrac,pron,14,7472.61,43747733396,6961359437,34282622, +cfrac,base,15,7425.09,44021522258,7052735620,34201447, +cfrac,pron,15,7382.99,43746403986,6961115525,34002974, +cfrac,base,16,7386.03,44021521121,7052739740,34282383, +cfrac,pron,16,7367.57,43745793482,6960975172,34156778, +cfrac,base,17,7395.83,44021240037,7052693979,34250574, +cfrac,pron,17,7355.32,43745690991,6960962082,34025801, +cfrac,base,18,7408.25,44021642439,7052754322,34159038, +cfrac,pron,18,7407.28,43747365015,6961287478,34189980, +cfrac,base,19,7388.83,44021467663,7052718765,34267466, +cfrac,pron,19,7423.09,43747748096,6961363058,34196513, +cfrac,base,20,7407.30,44025138261,7053811129,34040366, +cfrac,pron,20,7352.42,43745864943,6960989803,34018624, +cfrac,base,21,7435.90,44023248622,7053072029,34132634, +cfrac,pron,21,7391.73,43747164524,6961267678,34072514, +cfrac,base,22,7448.62,44023169099,7053060512,34183363, +cfrac,pron,22,7449.62,43749365715,6961677532,34268641, +cfrac,base,23,7453.63,44023874357,7053183635,34256732, +cfrac,pron,23,7442.19,43748631754,6961529667,34240104, +cfrac,base,24,7476.36,44024404544,7053282558,34271770, +cfrac,pron,24,7412.26,43747853132,6961393170,34168361, +cfrac,base,25,7443.90,44023206183,7053052467,34181802, +cfrac,pron,25,7465.71,43751382539,6962071849,34265746, +cfrac,base,26,7443.28,44022044614,7052847832,34130938, +cfrac,pron,26,7451.75,43748825133,6961584258,34202498, +cfrac,base,27,7440.44,44021998825,7052851995,34174372, +cfrac,pron,27,7413.83,43747237298,6961283493,34096130, +cfrac,base,28,7408.92,44021224911,7052689859,34614278, +cfrac,pron,28,7391.42,43746116555,6961050285,34098143, +cfrac,base,29,7398.32,44021171910,7052677754,34114944, +cfrac,pron,29,7387.59,43746240613,6961082620,34063635, +cfrac,base,30,7389.74,44022465177,7053125810,34080277, +cfrac,pron,30,7405.69,43747886748,6961397658,34103346, +cfrac,base,31,7393.88,44020949074,7052626450,34064066, +cfrac,pron,31,7396.48,43747186971,6961245750,34100110, +cfrac,base,32,7411.79,44021823226,7052787542,34114868, +cfrac,pron,32,7385.01,43746819125,6961180984,34185268, +cfrac,base,33,7384.90,44020843418,7052592205,34043053, +cfrac,pron,33,7386.45,43746866346,6961203351,34159637, +cfrac,base,34,7375.36,44020288979,7052500140,34029319, +cfrac,pron,34,7373.37,43746013734,6961031552,34098221, +cfrac,base,35,7403.00,44021589289,7052762704,34118055, +cfrac,pron,35,7373.69,43746200824,6961073492,34059132, +cfrac,base,36,7415.00,44021370337,7052709328,34065539, +cfrac,pron,36,7381.85,43746556474,6961142779,34127630, +cfrac,base,37,7376.83,44020090745,7052462035,34056221, +cfrac,pron,37,7382.23,43747290760,6961281865,34033916, +cfrac,base,38,7374.66,44021024752,7052645761,34210362, +cfrac,pron,38,7354.80,43745778355,6960985248,34004721, +cfrac,base,39,7408.65,44021593755,7052762074,34176658, +cfrac,pron,39,7378.73,43746334866,6961100931,34069297, +cfrac,base,40,7409.92,44023543745,7053361361,34070842, +cfrac,pron,40,7410.74,43747060113,6961229487,34117318, +cfrac,base,41,7374.33,44020576072,7052558210,34101368, +cfrac,pron,41,7373.70,43746164600,6961064538,34081594, +cfrac,base,42,7375.42,44020449074,7052529042,33977635, +cfrac,pron,42,7357.96,43745406822,6960912095,34017546, +cfrac,base,43,7406.85,44022192290,7052869546,34151807, +cfrac,pron,43,7357.18,43746587892,6961149248,34131706, +cfrac,base,44,7397.95,44021782586,7052790933,34093354, +cfrac,pron,44,7411.73,43747674538,6961359093,34123640, +cfrac,base,45,7403.59,44021853285,7052808758,34189961, +cfrac,pron,45,7399.29,43747588169,6961340286,34126097, +cfrac,base,46,7383.13,44021671666,7052775098,34220112, +cfrac,pron,46,7379.51,43746920307,6961205986,34132586, +cfrac,base,47,7389.00,44021875823,7052806282,34214154, +cfrac,pron,47,7378.68,43747095313,6961244022,34087644, +cfrac,base,48,7380.04,44021538507,7052745838,34056617, +cfrac,pron,48,7382.71,43747026891,6961227512,34206188, +cfrac,base,49,7401.12,44022184326,7052874209,34111752, +cfrac,pron,49,7379.85,43747036010,6961229213,34104548, +cfrac,base,50,7420.18,44022440190,7052927519,34151865, +cfrac,pron,50,7371.90,43750218827,6962245823,34084499, +cfrac,base,51,7370.09,44020202045,7052480044,33970751, +cfrac,pron,51,7379.79,43746766601,6961181210,34033051, +espresso,base,1,5056.45,32763687205,7463153975,221665700, +espresso,pron,1,5103.16,32662335147,7429455987,221503934, +espresso,base,2,5051.06,32763412251,7463081922,221458855, +espresso,pron,2,5107.51,32663420726,7429684668,221629535, +espresso,base,3,5092.74,32762181566,7462827868,221517087, +espresso,pron,3,5104.55,32662214096,7429432780,221653817, +espresso,base,4,5071.91,32763727986,7463142329,221639768, +espresso,pron,4,5113.80,32661993496,7429388936,221458209, +espresso,base,5,5086.32,32763788813,7463154014,221668518, +espresso,pron,5,5088.21,32662007486,7429391770,221307591, +espresso,base,6,5080.02,32763467885,7463085117,221531390, +espresso,pron,6,5101.07,32661815642,7429351079,221589298, +espresso,base,7,5064.15,32761909483,7462774159,221413269, +espresso,pron,7,5097.43,32662152795,7429416556,221501145, +espresso,base,8,5117.87,32763233814,7463037468,221642889, +espresso,pron,8,5087.52,32662403344,7429472468,221660639, +espresso,base,9,5070.33,32762081341,7462804139,221987858, +espresso,pron,9,5074.16,32661637582,7429316860,221557927, +espresso,base,10,5077.28,32763169170,7463023343,221611696, +espresso,pron,10,5071.61,32663193514,7429641700,221331850, +espresso,base,11,5118.25,32763552455,7463112917,221559692, +espresso,pron,11,5102.19,32661876084,7429361411,221511683, +espresso,base,12,5124.47,32763570021,7463109464,221646602, +espresso,pron,12,5115.13,32662273309,7429448866,221648837, +espresso,base,13,5060.90,32766319527,7463981840,221421724, +espresso,pron,13,5094.06,32663451710,7429686325,221471026, +espresso,base,14,5133.02,32763657627,7463117557,221596405, +espresso,pron,14,5117.99,32662882834,7429565704,221567227, +espresso,base,15,5067.16,32762229693,7462840322,221435789, +espresso,pron,15,5081.89,32663050440,7429611788,221705459, +espresso,base,16,5127.13,32765021045,7463402235,221718111, +espresso,pron,16,5106.46,32662345244,7429460558,221352695, +espresso,base,17,5072.80,32763155450,7463025649,221531200, +espresso,pron,17,5073.96,32661927666,7429366285,221402048, +espresso,base,18,5145.97,32763857584,7463155860,221727442, +espresso,pron,18,5075.82,32663170734,7429624991,221565225, +espresso,base,19,5128.94,32765525345,7463741268,221929086, +espresso,pron,19,5115.33,32663312578,7429645870,221622986, +espresso,base,20,5125.31,32764543156,7463300312,221539060, +espresso,pron,20,5116.61,32663096804,7429615875,221690206, +espresso,base,21,5136.11,32763131250,7463012881,221584355, +espresso,pron,21,5113.82,32662175049,7429413604,221559694, +espresso,base,22,5117.17,32764822427,7463356146,221702154, +espresso,pron,22,5098.26,32663680433,7429719520,221593048, +espresso,base,23,5133.18,32763080583,7462999854,221687222, +espresso,pron,23,5070.57,32661833494,7429342638,221601471, +espresso,base,24,5180.70,32764879261,7463347320,221639269, +espresso,pron,24,5094.86,32662110957,7429399649,221658279, +espresso,base,25,5058.58,32762391355,7462865519,221902014, +espresso,pron,25,5092.35,32662455535,7429468624,221441702, +espresso,base,26,5113.18,32763299677,7463038252,221568828, +espresso,pron,26,5121.12,32663228181,7429626458,221556729, +espresso,base,27,5115.59,32762917948,7462967042,221687911, +espresso,pron,27,5081.92,32665336625,7430349368,221424266, +espresso,base,28,5150.00,32763870518,7463159124,221907566, +espresso,pron,28,5102.37,32664111670,7429817658,221652235, +espresso,base,29,5054.42,32762872400,7462976784,221585334, +espresso,pron,29,5083.05,32665534362,7430084840,221490446, +espresso,base,30,5105.16,32770150312,7464415702,221791882, +espresso,pron,30,5118.20,32668332636,7430652006,221716161, +espresso,base,31,5061.91,32768063245,7463988252,221665995, +espresso,pron,31,5113.93,32668955415,7430779556,221772103, +espresso,base,32,5151.46,32769274803,7464236859,221794998, +espresso,pron,32,5130.91,32665344356,7430059262,221744004, +espresso,base,33,5055.70,32771163248,7464610831,221612507, +espresso,pron,33,5077.27,32666510972,7430276052,221668282, +espresso,base,34,5164.32,32770647070,7464511037,221914976, +espresso,pron,34,5067.21,32664951029,7429968858,221505003, +espresso,base,35,5086.26,32770793018,7464529889,221974024, +espresso,pron,35,5100.56,32669186330,7430813049,221807370, +espresso,base,36,5153.75,32769017226,7464183073,221785074, +espresso,pron,36,5064.24,32665211393,7430033210,221827059, +espresso,base,37,5080.94,32768057829,7463986157,221782597, +espresso,pron,37,5084.09,32667661691,7430502549,221564818, +espresso,base,38,5063.35,32767955189,7463980173,221550501, +espresso,pron,38,5091.98,32667005741,7430385912,221709761, +espresso,base,39,5053.99,32769802437,7464341748,221667846, +espresso,pron,39,5088.10,32666257898,7430223399,221723178, +espresso,base,40,5127.02,32766450837,7463670615,221674764, +espresso,pron,40,5091.00,32670367496,7431040726,221750414, +espresso,base,41,5075.12,32763686170,7463127186,221708473, +espresso,pron,41,5063.11,32661886483,7429360202,221484761, +espresso,base,42,5097.02,32766173356,7463870790,221666365, +espresso,pron,42,5068.60,32661948206,7429371882,221576132, +espresso,base,43,5087.96,32762534670,7462886999,221623011, +espresso,pron,43,5090.05,32662604664,7429506319,221705025, +espresso,base,44,5112.13,32763549093,7463100515,221633379, +espresso,pron,44,5111.82,32662619503,7429511053,221579932, +espresso,base,45,5048.10,32762150432,7462812042,221343169, +espresso,pron,45,5083.68,32662112551,7429402089,221627471, +espresso,base,46,5134.10,32763704164,7463129103,221693928, +espresso,pron,46,5078.36,32662345655,7429452382,221599736, +espresso,base,47,5055.92,32762018089,7462797420,221422046, +espresso,pron,47,5097.42,32661724502,7429331284,221597261, +espresso,base,48,5086.46,32764702211,7463329082,221401117, +espresso,pron,48,5098.84,32661706907,7429323474,221609249, +espresso,base,49,5123.85,32762651237,7462915441,221562494, +espresso,pron,49,5087.26,32664259345,7429841489,221767755, +espresso,base,50,5086.11,32762880631,7462966890,221527257, +espresso,pron,50,5101.90,32663168624,7429633940,221507324, +espresso,base,51,5054.97,32762438280,7462879032,221384109, +espresso,pron,51,5095.03,32663006149,7429594918,221555128, +sh6bench1,base,1,1484.15,12607717357,3082540157,3891780,1.4818 +sh6bench1,pron,1,1537.31,12054978114,2898433005,3868555,1.5352 +sh6bench1,base,2,1481.31,12606579155,3082283052,3862233,1.4792 +sh6bench1,pron,2,1537.94,12054654543,2898387216,3867074,1.5358 +sh6bench1,base,3,1487.93,12604800653,3081912145,3829551,1.4858 +sh6bench1,pron,3,1536.93,12053958481,2898227412,3841841,1.5348 +sh6bench1,base,4,1479.66,12606734943,3082313654,3862827,1.4775 +sh6bench1,pron,4,1521.93,12053221979,2898073460,3846655,1.5198 +sh6bench1,base,5,1489.05,12605349261,3082027149,3848789,1.4870 +sh6bench1,pron,5,1538.39,12054122106,2898253989,3850562,1.5363 +sh6bench1,base,6,1473.30,12604861223,3081944237,3847613,1.4712 +sh6bench1,pron,6,1548.87,12053954399,2898221222,3856753,1.5468 +sh6bench1,base,7,1490.23,12605358514,3082036048,3849938,1.4881 +sh6bench1,pron,7,1528.48,12054234339,2898282866,3864595,1.5263 +sh6bench1,base,8,1492.49,12605160630,3081984400,3847919,1.4904 +sh6bench1,pron,8,1512.89,12054426047,2898320207,3860592,1.5108 +sh6bench1,base,9,1515.69,12605800523,3082123573,3884622,1.5134 +sh6bench1,pron,9,1536.82,12054164140,2898267618,3851466,1.5347 +sh6bench1,base,10,1486.81,12605062339,3081964215,3836544,1.4847 +sh6bench1,pron,10,1564.66,12054612348,2898364335,3869961,1.5623 +sh6bench1,base,11,1479.01,12605798411,3082124958,3842994,1.4768 +sh6bench1,pron,11,1546.47,12052473600,2897927291,3846741,1.5442 +sh6bench1,base,12,1476.68,12606319872,3082243643,3875398,1.4746 +sh6bench1,pron,12,1528.62,12055377948,2898517523,3870087,1.5264 +sh6bench1,base,13,1480.55,12604272402,3081802891,3831427,1.4784 +sh6bench1,pron,13,1522.32,12053973438,2898238040,3857593,1.5202 +sh6bench1,base,14,1490.99,12605046072,3081960367,3832290,1.4889 +sh6bench1,pron,14,1544.26,12055155959,2898461205,3871784,1.5422 +sh6bench1,base,15,1500.36,12604989903,3081949429,3857426,1.4982 +sh6bench1,pron,15,1528.93,12054446190,2898311724,3845378,1.5268 +sh6bench1,base,16,1476.21,12605055681,3081971678,3845939,1.4741 +sh6bench1,pron,16,1546.07,12059186391,2899646338,3874935,1.5440 +sh6bench1,base,17,1488.46,12605715833,3082109681,3863838,1.4863 +sh6bench1,pron,17,1549.35,12054739191,2898392301,3871505,1.5472 +sh6bench1,base,18,1479.22,12605944672,3082171794,3859951,1.4771 +sh6bench1,pron,18,1537.44,12053661406,2898166084,3845373,1.5353 +sh6bench1,base,19,1492.38,12604944658,3081964720,3860436,1.4901 +sh6bench1,pron,19,1533.36,12054433249,2898305772,3843339,1.5312 +sh6bench1,base,20,1470.77,12605988216,3082153930,3850372,1.4686 +sh6bench1,pron,20,1535.71,12053526681,2898122180,3832159,1.5335 +sh6bench1,base,21,1488.34,12605780048,3082117295,3886524,1.4862 +sh6bench1,pron,21,1527.57,12056698719,2898790311,3922553,1.5254 +sh6bench1,base,22,1478.18,12604785616,3081930523,3850330,1.4760 +sh6bench1,pron,22,1522.94,12054801122,2898409443,3871080,1.5208 +sh6bench1,base,23,1490.18,12605218994,3082007648,3853652,1.4879 +sh6bench1,pron,23,1540.77,12055271828,2898483475,3873275,1.5387 +sh6bench1,base,24,1494.37,12605002021,3081968601,3866336,1.4923 +sh6bench1,pron,24,1536.18,12054662014,2898378273,3874253,1.5341 +sh6bench1,base,25,1475.44,12603905183,3081724289,3810384,1.4734 +sh6bench1,pron,25,1535.24,12055228184,2898483631,3878145,1.5331 +sh6bench1,base,26,1482.14,12604944853,3081949583,3841874,1.4800 +sh6bench1,pron,26,1540.59,12055300311,2898489021,3876805,1.5385 +sh6bench1,base,27,1461.93,12607015902,3082368283,3885909,1.4597 +sh6bench1,pron,27,1543.86,12054386657,2898312259,3869710,1.5417 +sh6bench1,base,28,1474.55,12605087791,3081976697,3843653,1.4724 +sh6bench1,pron,28,1544.82,12054346830,2898293666,3849422,1.5427 +sh6bench1,base,29,1479.36,12606525348,3082268674,3858666,1.4773 +sh6bench1,pron,29,1532.67,12053895268,2898215514,3844239,1.5306 +sh6bench1,base,30,1481.10,12604783519,3081912610,3826871,1.4790 +sh6bench1,pron,30,1520.54,12053661621,2898168537,3838070,1.5184 +sh6bench1,base,31,1486.21,12606033096,3082167517,3859688,1.4841 +sh6bench1,pron,31,1537.78,12054538689,2898341907,3867892,1.5356 +sh6bench1,base,32,1469.10,12606093076,3082180984,3859715,1.4670 +sh6bench1,pron,32,1530.49,12053844074,2898207833,3858169,1.5284 +sh6bench1,base,33,1495.32,12604819429,3081925270,3877017,1.4932 +sh6bench1,pron,33,1542.35,12055314738,2898511475,3888562,1.5400 +sh6bench1,base,34,1475.30,12605987287,3082160209,3849347,1.4732 +sh6bench1,pron,34,1544.27,12054856063,2898406301,3866658,1.5421 +sh6bench1,base,35,1474.13,12605960487,3082171885,3875804,1.4720 +sh6bench1,pron,35,1546.12,12053566570,2898122119,3834662,1.5440 +sh6bench1,base,36,1482.50,12606575048,3082289652,3897216,1.4803 +sh6bench1,pron,36,1546.79,12053598328,2898152975,3843800,1.5447 +sh6bench1,base,37,1463.15,12605047729,3081979281,3846971,1.4610 +sh6bench1,pron,37,1529.99,12053887354,2898232920,3878469,1.5279 +sh6bench1,base,38,1475.71,12604988035,3081947457,3835214,1.4736 +sh6bench1,pron,38,1537.13,12052561846,2897931785,3832485,1.5350 +sh6bench1,base,39,1478.77,12604771028,3081922540,3849922,1.4767 +sh6bench1,pron,39,1534.52,12053562684,2898142420,3844737,1.5324 +sh6bench1,base,40,1481.87,12606071258,3082172290,3853813,1.4798 +sh6bench1,pron,40,1538.63,12055851953,2898613170,3880435,1.5365 +sh6bench1,base,41,1500.97,12605687934,3082092063,3867852,1.4987 +sh6bench1,pron,41,1531.34,12053788845,2898192219,3849307,1.5292 +sh6bench1,base,42,1473.48,12604860421,3081925596,3831125,1.4714 +sh6bench1,pron,42,1546.33,12054281719,2898291993,3862599,1.5442 +sh6bench1,base,43,1478.10,12604835563,3081925193,3828870,1.4760 +sh6bench1,pron,43,1524.85,12053541092,2898137440,3842072,1.5227 +sh6bench1,base,44,1485.22,12605698935,3082096565,3842973,1.4831 +sh6bench1,pron,44,1583.08,12055043807,2898426724,3866368,1.5807 +sh6bench1,base,45,1482.78,12604773296,3081930417,3852333,1.4806 +sh6bench1,pron,45,1535.57,12054050110,2898236192,3855294,1.5335 +sh6bench1,base,46,1484.52,12605384651,3082045675,3851240,1.4822 +sh6bench1,pron,46,1532.72,12054485136,2898342312,3879147,1.5306 +sh6bench1,base,47,1486.65,12606970065,3082362758,3881357,1.4844 +sh6bench1,pron,47,1535.46,12055701584,2898580237,3889981,1.5333 +sh6bench1,base,48,1481.46,12604845181,3081928239,3829735,1.4794 +sh6bench1,pron,48,1509.38,12054381102,2898304839,3848551,1.5072 +sh6bench1,base,49,1475.39,12604661518,3081889168,3835949,1.4733 +sh6bench1,pron,49,1527.11,12053852780,2898202799,3843280,1.5250 +sh6bench1,base,50,1481.97,12605224649,3082006203,3841011,1.4798 +sh6bench1,pron,50,1531.61,12053923152,2898224495,3843977,1.5295 +sh6bench1,base,51,1468.85,12604356271,3081809590,3810580,1.4667 +sh6bench1,pron,51,1543.52,12053889527,2898213665,3869772,1.5414 diff --git a/bench/single-threaded/scripts/analyze_micro.py b/bench/single-threaded/scripts/analyze_micro.py new file mode 100755 index 000000000..bd0a0a200 --- /dev/null +++ b/bench/single-threaded/scripts/analyze_micro.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +"""Analyze microbenchmark samples: median + p90/p99, IPC, Mann-Whitney U and a +95% bootstrap CI of the (variant - baseline) median delta. Baseline variant is +the one literally named 'baseline' (override with --baseline). + +Usage: analyze_micro.py micro.csv [--metric cycles] [--baseline baseline] +""" +import csv, sys, math, random, statistics as st +from collections import defaultdict + +def pct(xs, p): + xs = sorted(xs); k = (len(xs)-1)*p/100.0; lo = int(k); hi = min(lo+1, len(xs)-1) + return xs[lo] + (xs[hi]-xs[lo])*(k-lo) + +def mwu(a, b): + comb = sorted([(v,0) for v in a] + [(v,1) for v in b]); n1, n2 = len(a), len(b) + rs = [0.0, 0.0]; i = 0 + while i < len(comb): + j = i + while j < len(comb) and comb[j][0] == comb[i][0]: j += 1 + avg = (i+1+j)/2.0 + for k in range(i, j): rs[comb[k][1]] += avg + i = j + U1 = rs[0] - n1*(n1+1)/2.0; U = min(U1, n1*n2 - U1) + mu = n1*n2/2.0; sd = (n1*n2*(n1+n2+1)/12.0)**0.5 + if sd == 0: return 1.0 + z = (U - mu)/sd + return max(min(2*(1 - 0.5*(1+math.erf(abs(z)/2**0.5))), 1.0), 0.0) + +def boot_ci(a, b, it=20000): + ds = sorted(st.median([random.choice(b) for _ in b]) - + st.median([random.choice(a) for _ in a]) for _ in range(it)) + return ds[int(0.025*it)], ds[int(0.975*it)] + +def main(): + path = sys.argv[1] + metric = "cycles"; baseline = "baseline"; seed = 12345 + for i, a in enumerate(sys.argv): + if a == "--metric": metric = sys.argv[i+1] + if a == "--baseline": baseline = sys.argv[i+1] + if a == "--seed": seed = int(sys.argv[i+1]) + random.seed(seed) # deterministic bootstrap CI for reproducible analysis + d = defaultdict(lambda: defaultdict(lambda: defaultdict(list))) + with open(path) as f: + for r in csv.DictReader(f): + wl = r.get("workload") or r.get("mode") # accept either column name + for k in ("cycles", "instructions"): + if r.get(k): d[wl][r["variant"]][k].append(float(r[k])) + for wl in d: + variants = list(d[wl]); base = d[wl].get(baseline, {}) + bvals = base.get(metric, []) + bmed = st.median(bvals) if bvals else float("nan") + print(f"\n=== {wl} (metric={metric}, baseline median={bmed:,.0f}) ===") + for v in variants: + xs = d[wl][v].get(metric, []) + if not xs: continue + m = st.median(xs) + cyc = d[wl][v].get("cycles"); ins = d[wl][v].get("instructions") + ipc = (st.median(ins)/st.median(cyc)) if (cyc and ins) else float("nan") + line = (f" {v:9s} p50={m:14,.0f} p90={pct(xs,90):14,.0f} " + f"p99={pct(xs,99):14,.0f} ipc={ipc:.3f}") + if v != baseline and bvals: + p = mwu(bvals, xs); lo, hi = boot_ci(bvals, xs) + sig = "SIGNIFICANT" if p < 0.05 else "ns" + excl = "excludes 0" if (lo < 0) == (hi < 0) else "INCLUDES 0" + line += (f"\n vs {baseline}: {(m-bmed)/bmed*100:+.2f}% " + f"p={p:.2e} ({sig}) 95%CI=[{lo:,.0f},{hi:,.0f}] ({excl})") + print(line) + +if __name__ == "__main__": + main() diff --git a/bench/single-threaded/scripts/build_variants.sh b/bench/single-threaded/scripts/build_variants.sh new file mode 100755 index 000000000..00256803c --- /dev/null +++ b/bench/single-threaded/scripts/build_variants.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +# Build the mimalloc variants used in the single-threaded analysis. +# +# baseline : current branch, default build (MI_SINGLE_THREADED off) +# single : current branch, -DMI_SINGLE_THREADED=ON (the deliverable) +# +# The "single-list" (rejected) experiment lives on the `single-threaded-sota` +# branch; check it out and re-run this script to build it the same way. +# +# Usage: bench/single-threaded/scripts/build_variants.sh [] +# Output: /{baseline,single}/libmimalloc.so* +set -euo pipefail + +here="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" # repo root +out="${1:-/tmp/mi-st-build}" +jobs="$(nproc)" + +build() { # + local name="$1"; shift + local d="$out/$name" + echo ">> building '$name' in $d" + rm -rf "$d"; mkdir -p "$d" + ( cd "$d" && cmake "$here" -DCMAKE_BUILD_TYPE=Release "$@" >cmake.log 2>&1 \ + && cmake --build . -j "$jobs" >make.log 2>&1 ) + echo " -> $(ls "$d"/libmimalloc.so.*.* 2>/dev/null | grep -E '\.[0-9]+$' | head -1)" +} + +build baseline +build single -DMI_SINGLE_THREADED=ON +echo "done. libs under $out/{baseline,single}/" diff --git a/bench/single-threaded/scripts/run_micro.sh b/bench/single-threaded/scripts/run_micro.sh new file mode 100755 index 000000000..64d8a49e5 --- /dev/null +++ b/bench/single-threaded/scripts/run_micro.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# +# Allocator-bound microbenchmark sweep: interleaved, pinned, perf-counter based. +# Compares any number of prebuilt mimalloc shared libraries on the `churn` +# microbenchmark (pure LIFO + windowed reuse). Emits raw per-run samples to CSV. +# +# Usage: +# build_variants.sh /tmp/mi-st-build +# run_micro.sh /tmp/mi-st-build/baseline/libmimalloc.so. baseline \ +# /tmp/mi-st-build/single/libmimalloc.so. single +# analyze_micro.py micro.csv +# +# Env: CORE (default 4), REPEATS (default 21), OUT (default ./micro.csv) +set -euo pipefail +here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +CORE="${CORE:-4}"; REPEATS="${REPEATS:-21}"; OUT="${OUT:-micro.csv}" +PIN="taskset -c $CORE" + +# (label -> libpath) pairs from argv: lib1 label1 lib2 label2 ... +libs=(); labels=() +while [ $# -ge 2 ]; do libs+=("$1"); labels+=("$2"); shift 2; done +[ $# -eq 0 ] || { echo "error: leftover argument '$1' (need