Fluree’s binaries use mimalloc as their global allocator (see Memory Allocator). In November 2026 we measured whether to move from mimalloc v2 to v3. This page records what we tested, what we measured and what we concluded, so the next evaluation can start from here.

Decision

Stay on mimalloc v2.2.4, pinned exactly in the workspace Cargo.toml:

mimalloc = { version = "=0.1.48", default-features = false }
libmimalloc-sys = { version = "=0.1.44", default-features = false }

No v3 release we tested is both better across our workloads and available from an official crate:

  • v3.7.0 (with or without upstream’s later huge-page fix) serves 21–28% more reads under a write and indexing load, but is 10–19% slower on BSBM, a read-only benchmark. BSBM’s product-detail query (Q2) runs twice as slowly.
  • v3.4.5 is 3% faster on BSBM and level on DBLP overall, with faster writes and lower peak memory. It doesn’t get v3.7.0’s read gain under writes, its regex queries on DBLP are 11–26% slower, and no crate has ever shipped it.
  • v3.3.2, the only v3 on the crates.io mimalloc crate, has a known bug that affects processes using more than 4 GiB (see Known upstream issues). Not measured on Fluree.

Why the pin is exact

mimalloc 0.1.49+ and libmimalloc-sys 0.1.49+ build mimalloc v3 by default. With a caret requirement (mimalloc = "0.1"), a routine cargo update moves every binary and the Python extension to v3.3.2 with no code change. mimalloc 0.1.48 accepts any libmimalloc-sys 0.1.44 or later, so pinning it alone isn’t enough: libmimalloc-sys is pinned too, and declared beside mimalloc in each crate that uses it so the pin holds whichever of them keeps mimalloc.

What we tested

ArmmimallocHow it was built
v2.2.42.2.4crates.io mimalloc 0.1.48 + libmimalloc-sys 0.1.44 (the pin above)
v3.7.03.7.0upstream’s own Rust crate, git = "https://github.com/microsoft/mimalloc", tag = "v3.7.0"
v3.7.0 + fix3.7.0 plus upstream’s huge-page fixthe same crate at rev = "aac4f5f47531cf7a22d3d4d85a7fb0b5ab206193" (v3.7.0 plus only that fix)
v3.4.53.4.5git = "https://github.com/xonatius/mimalloc_rust", rev = "6d4c41bb10c6d9da1d1b6f07b38c4cc051667f11": the branch of the open update to the crates.io crate (purpleprotocol/mimalloc_rust PR #169); its C sources are upstream’s v3.4.5 tag
v2.3.22.3.2crates.io mimalloc 0.1.52 with the v2 feature (first round only)

All arms in a round were built from the same Fluree commit with the same profile (release in the first round, dist in the final round). To confirm which mimalloc a stripped binary contains, look for option names: v3 has page_cross_thread_max_reclaim, which v2 lacks; v3.6 and later also have arena_purge_min_size, which v3.4.5 and v3.5 lack. MIMALLOC_VERBOSE=1 prints the options in effect at startup, which confirms that an environment setting took hold.

Workloads

  • BSBM explore, 100M scale, server m7a.4xlarge (16 vCPU, 64 GB), separate m7a.2xlarge load generator. Per client count: a calibration pilot, then three repeats sized to about 180 s, each on a fresh server after a COUNT check and 1,000 warm-up mixes. Reported as query mixes per hour (QMpH), median of the three repeats.
  • SPARQLoscope on DBLP-core: 561M triples, 105 queries, m7a.4xlarge. Page cache dropped and re-warmed, fresh server, one warm-up and three timed runs per query (-w 1 -r 3 -t 180).
  • Write and indexing soak: m7a.4xlarge, LUBM-25 imported fresh per run, default cache. Two writers at 4 transactions per second each, 1,000 triples per transaction, with background indexing at its defaults; four closed-loop readers over 14 LUBM queries (no reasoning). 10 minutes of load, then 2 minutes idle.
  • Synthetic retention probe: 8 threads allocate about 5 GiB of objects, then free them all (“clean”) or keep 1 object in 10 alive (“fragmented”, about 424 MiB live); resident memory is read 20 s later. Linux, transparent huge pages (THP) in madvise mode.

Results

Final round (Fluree 5.0.0-alpha.4 plus seven unrelated query commits)

BSBM explore, 16 vCPU, QMpH:

Clientsv2.2.4v3.4.5v3.7.0 + fixv3.7.0
155,32257,108 (+3%)49,892 (−10%)49,133 (−11%)
16695,500713,049 (+3%)561,988 (−19%)580,680 (−17%)
32893,243918,360 (+3%)773,659 (−13%)760,945 (−15%)

A repeat of v2.2.4 at 16 clients at the end of the session measured 698,211 (+0.4%). The v3.4.5 repeats stayed within 2% of each other at every client count; the v3.7.0 repeats spread up to 10%.

Average query execution time in ms, median of the three repeats (explore Q6 is not part of the mix):

Query1 client: v2.2.4v3.4.5v3.7.0 + fixv3.7.0
Q14.5544.5104.5514.567
Q21.1840.9912.3592.403
Q35.8535.7975.5365.573
Q48.2168.1197.7437.846
Q514.5214.4414.5214.74
Q71.0761.0161.2171.252
Q80.7060.6790.7480.765
Q90.3460.3330.3770.387
Q100.6000.5840.6010.617
Q110.3950.3860.4160.424
Q120.4790.4620.5040.512
Query16 clients: v2.2.4v3.4.5v3.7.0 + fixv3.7.0
Q15.3065.2206.0235.880
Q21.8081.5763.6453.311
Q36.9746.8526.8506.892
Q49.5269.4149.3629.508
Q516.5516.6919.6919.20
Q71.6121.5461.9081.855
Q81.2101.1871.3241.313
Q90.7750.7660.8720.863
Q101.0941.0761.1541.143
Q110.7660.7520.8270.819
Q120.8780.8690.9680.956

Q2 runs 6 times per mix, so at 1 client it accounts for nearly all of the v3.7.0 loss. At 16 clients most other queries are also 4–19% slower in both v3.7.0 arms (Q3 and Q4 are level), and v3.4.5 is within 1% or faster on every query.

DBLP-core, one sweep per arm (median ms):

v2.2.4v3.4.5v3.7.0 + fixv3.7.0
Sum of 105 query medians21.41 s21.39 s21.45 s22.72 s
Geometric mean15.6815.8015.8616.04
exists-join-3-chain-22259223022972646
minus-join-3-chain-22264223223202618
minus-join-3-star-11126109310861286
result-size-xlarge4381442642594620
group-by-count-object-low-multiplicity112.8112.7129.7129.6
regex-3521577598578
regex-3-fixed384485486483
Peak server memory17.6 GB16.3 GB15.7 GB15.7 GB

All 105 queries passed in every arm.

Write and indexing soak (two runs per arm):

Reads/sMedian readMedian write99th-percentile write
v2.2.446.1 / 45.66.8 / 8.4 ms12.4 / 12.1 ms289 / 343 ms
v3.4.547.0 / 46.65.9 / 5.9 ms10.9 / 11.1 ms202 / 166 ms
v3.4.5, MIMALLOC_ARENA_PURGE_MULT=4 (one run)50.65.5 ms10.8 ms189 ms
v3.7.0 + fix58.3 / 59.25.2 / 5.1 ms10.9 / 10.6 ms147 / 161 ms
v3.7.057.6 / 55.15.4 / 5.5 ms10.7 / 10.7 ms172 / 252 ms

Peak memory under load was 26.8–29.2 GB in every arm, mostly the query cache filling to its budget (35% of RAM by default).

First round (Fluree 5.0.0-alpha.4)

Write and indexing soak, same settings, two rounds in rotated order:

Reads/sMedian readMedian write99th-percentile write
v2.2.445.9 / 47.07.9 / 7.7 ms12.2 / 12.5 ms213 / 223 ms
v2.3.245.1 / 45.36.9 / 7.0 ms12.6 / 12.5 ms357 / 249 ms
v3.7.056.2 / 56.25.3 / 5.0 ms10.7 / 10.7 ms128 / 181 ms
v3.7.0, MIMALLOC_ALLOW_THP=152.0 / 51.35.6 / 5.9 ms10.9 / 10.9 ms181 / 255 ms

The same soak with the cache capped at 4 GB (FLUREE_CACHE_MAX_MB=4096), 20 minutes of load and 3 minutes idle, one round:

Reads/sMedian writeMemory outside the cache, idlePeak RSS
v2.2.449.316.4 ms6.5 GB12.5 GB
v2.3.248.216.8 ms6.1 GB11.9 GB
v3.7.054.213.7 ms7.0 GB11.0 GB
v3.7.0, MIMALLOC_ALLOW_THP=150.513.7 ms5.3 GB10.6 GB

LUBM-25 import (14.5–14.9 s, 1.2 GB peak) and single-client hot LUBM queries (geometric mean within 1%) were the same in every arm. Those queries take a few milliseconds each and allocate little, which is why this round did not reveal the BSBM and DBLP losses.

Synthetic retention probe, resident memory 20 s after the free (MiB):

Clean freeFragmented
v2.2.42,688 (of 5,251 peak)4,697
v2.3.2124,651
v3.3.22551,896
v3.7.07533,369
v3.7.0, MIMALLOC_ALLOW_THP=1about 501,183
v3.7.0, MIMALLOC_ALLOW_THP=0about 231,048

v2.2.4 kept about half of the clean-freed memory until a forced mi_collect(true). In the fragmented case, v3.7.0 at its defaults keeps more than with ALLOW_THP at 0 or 1 because it purges only whole 2 MiB ranges, so as not to split huge pages.

DBLP diagnosis of v3.7.0

These runs compared v3.7.0 with v2.2.4 on DBLP-core before the upstream fix was known.

  • The heavy-join gap depends on query order. Run first on a fresh server, v3.7.0 is as fast as v2.2.4 on the multi-second joins, or faster. After a full 105-query sweep, v2.2.4 runs them 14–17% faster than it did on the fresh server, and v3.7.0 doesn’t change.
  • Page faults explain the gap; TLB misses don’t. Per block of the six heaviest queries ×5, v2.2.4 took 3.06M page faults before the sweep and 0.33–0.63M after it. v3.7.0 took about 3.6M in every block. dTLB misses did not fall for v2.2.4 after the sweep, and memory on 2 MB pages ended at similar levels in both.
  • Settings that didn’t help v3.7.0: MIMALLOC_PURGE_DELAY=-1 (never return freed memory) changed neither latency nor faults. MIMALLOC_ALLOW_THP=1 performed like the default. MIMALLOC_ALLOW_THP=0 was the worst: 5–10% slower on the heavy joins with 1.5–2× the faults.
  • The group-by-count-object-low-multiplicity slowdown is in our code’s cycles, not the allocator’s. A CPU profile put the extra 15% inside group_count_v6 and offer_topk, with no mimalloc function above 0.3%. That points to data placement or code layout. v3.4.5 doesn’t have it.

The upstream huge-page fix (next section) matches the fault pattern and removed the heavy-join gap in the final round. It did not change BSBM.

What is established and what isn’t

Established:

  • The BSBM loss and the group-by-count slowdown come from a change between v3.4.5 and v3.7.0 other than the huge-page bug. Both v3.7.0 arms show them; v3.4.5 doesn’t.
  • The DBLP heavy-join loss was the huge-page bug: the fix removed it.
  • The regex-3 and regex-3-fixed slowdowns are in every v3 arm, v3.4.5 included. They come from one sweep per arm, but all three v3 arms agree.
  • Part of v3.7.0’s read gain under writes comes from returning freed memory less often: v3.4.5 with v3.7.0’s arena purge multiplier (4000 ms instead of 1000 ms) gained 10% instead of 2%.

Not established:

  • Which upstream commit causes the BSBM Q2 regression. It lies between v3.4.5 and v3.7.0.
  • Whether the same change also gives v3.7.0 the rest of its read gain under writes.
  • How MIMALLOC_ARENA_PURGE_MULT=4 on v3.4.5 does on BSBM. It wasn’t measured.
  • What causes the regex slowdowns.
  • How mimalloc v2.5.x, the newer v2 line, performs. It wasn’t tested.

Known upstream issues

IssueAffectsFixed in
Uses OS memory instead of arenas once the process uses more than 4 GiBv3 before 3.4.1, so the crates.io crate’s v3.3.2v3.4.1 (release notes, 2026-07-14)
On macOS, every mimalloc v3 copy in a process shares fixed thread-local slots, so a Python extension using mimalloc v3 can crash under CPython 3.14, which ships its own copy (#1327)v3.3.2v3.4.4
Some page allocations taken directly from the OS don’t get the transparent-huge-page hint, so they fault in 4 KiB pages (#1502; introduced in commit 67b324e)v3.5.0 to v3.7.0commits e2a1f17 and aac4f5f, 2026-11-18; not in a release as of 2026-11-23

Purge defaults, which govern how soon freed memory goes back to the OS:

purge_delayarena_purge_multEffective arena delayallow_thp
v2.2.410 ms10100 ms(no such option)
v3.4.51000 ms11000 ms1
v3.7.01000 ms44000 ms2 (purge only whole 2 MiB ranges)

Crate availability

No crate has ever shipped mimalloc v3.4.x.

CratePublishermimalloc it bundles
mimalloc / libmimalloc-sys (crates.io)purpleprotocol0.1.48: v2.2.4 (v3.1.5 behind a v3 feature). From 0.1.49: v3 by default, v2 with the v2 feature. The latest, 0.1.52 (May 2026), bundles v3.3.2 and v2.3.2.
mimalloc (upstream contrib/rust)Microsoft, not on crates.iofrom v3.6.0 (added 2026-10-17); usable as a git dependency at a release tag
mimalloc3 / libmimalloc-sys3 (crates.io)third partyv3.5.0 (August 2026) to v3.7.0
mimalloc-safe (crates.io)napi-rsv2 only, 2.3.2 to 2.5.2

When to look again

Look again when one of these happens:

  • An upstream v3 release fixes the BSBM Q2 regression. Bisecting v3.4.5..v3.7.0 with a 1-client BSBM run would find the commit and could be reported upstream.
  • A v3 release at or after v3.4.5 reaches an official crate, for example the crates.io mimalloc crate once PR #169 or a later update is published.
  • mimalloc v2.5.x is worth a look as a newer v2.

A candidate must:

  • come from an official crate (crates.io mimalloc, or upstream’s own crate at a release tag);
  • have no open issue affecting processes larger than 4 GiB.

How to run the comparison

  • Build every arm from the same Fluree commit, and run the v2.2.4 arm in the same session on the same machines. Repeat one v2.2.4 cell at the end to check for drift.
  • Run all three workloads. The soak alone misses read-only losses, and BSBM alone misses the gain under writes.
  • Use machines nothing else is running on. An overlapping job inflated tail-latency numbers once during this evaluation.
  • On DBLP, compare full sweeps, not queries run in isolation. v2’s heap state after earlier queries affects the heavy joins.
  • Check MIMALLOC_VERBOSE=1 output whenever a run sets a mimalloc environment variable.

What to compare

  • BSBM: QMpH at 1, 16 and 32 clients, and the Q2 and Q5 execution times.
  • DBLP: the sum of query medians, the heavy joins (exists-join-3-chain-2, minus-join-3-chain-2, minus-join-3-star-1), group-by-count-object-low-multiplicity, regex-3, regex-3-fixed, result-size-xlarge, and peak memory.
  • Soak: reads per second, median and 99th-percentile write latency, and idle memory outside the cache.