Skip to content

Commit 47b4b08

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Drop mimalloc (#6231)
When 6a29c2d ("mingw: use mimalloc", 2019-06-24) introduced the vendored mimalloc, the comparison was against `nedmalloc` (which by then had not seen an upstream commit since 2014, and whose repository was archived in 2019). The two were essentially at parity in that benchmark; mimalloc was chosen because it was actively developed. I do not really recall whether the platform's *default* allocator was not part of the comparison; If it was, the performance was still worse than mimalloc, if it wasn't, I forgot to test ;-) Six years on, with `nedmalloc` safely on its way to being dropped from the upstream codebase entirely (gitgitgadget#2104, currently in `seen` as e576abb), the question is no longer "mimalloc vs nedmalloc" but "mimalloc vs the OS allocator". Re-running the same `git repack -adfq` benchmark against each platform's current default allocator finds no measurable speedup from mimalloc on any of Windows, macOS, or Linux. ## Methods I recapitulated the same benchmark as cited in 6a29c2d (the original comparison was nedmalloc vs mimalloc on `git repack -adfq` over a subset of `linux.git`), now extended to the three GitHub-hosted runners (`ubuntu-latest`, `macos-latest`, `windows-latest`). Each job built two `git` binaries from the same source tree, vanilla and `USE_MIMALLOC=YesPlease`, then prepared a fresh bare clone of `linux.git` to a fixed `SHA`, and ran the repacks with both built `git`s in randomized order for five iterations. Each iteration ran both binaries exactly once on a freshly `copytree`-ed copy of the immutable template repository; the order *within* an iteration was randomized so any per-iteration confounder (cache state, runner warm-up, neighbour-VM contention) would be shared symmetrically between variants. Timings excluded the `copytree`. The full driver is the Python script `ci/bench-mimalloc.py` on the [`mimalloc-benchmark` branch](https://github.com/dscho/git/tree/mimalloc-benchmark/ci). ## Results: original `linux v2.6.20`-era workload (49,917 commits, 431,605 objects, ~204 MB pack) | Platform | vanilla mean ± stdev | mimalloc mean ± stdev | Δ (mimalloc − vanilla) | |---|---|---|---| | `ubuntu-latest` | 27.089s ± 0.060s | 27.041s ± 0.065s | −0.048s (−0.18%) | | `macos-latest` | 23.259s ± 1.206s | 25.076s ± 2.279s | +1.817s (+7.8%) | | `windows-latest` | 29.828s ± 1.651s | 30.329s ± 2.428s | +0.501s (+1.7%) | Workflow run: https://github.com/dscho/git/actions/runs/25374127848 ## Results: 4x larger `linux v3.0` workload (255,039 commits, 2,059,429 objects, ~788 MB pack) | Platform | vanilla mean ± stdev | mimalloc mean ± stdev | Δ (mimalloc − vanilla) | |---|---|---|---| | `ubuntu-latest` | 134.723s ± **0.329s** | 134.801s ± **0.191s** | +0.078s (+0.06%) | | `macos-latest` | 130.183s ± 19.098s | 133.292s ± 18.991s | +3.109s (+2.4%) | | `windows-latest` | 145.183s ± 1.272s | 146.271s ± 4.161s | +1.088s (+0.75%) | Workflow run: https://github.com/dscho/git/actions/runs/25376885309 ## Discussion The Linux numbers on the larger workload are particularly clear: stdev is below 0.3% of the mean for both variants, and the difference is well inside that floor. Glibc's allocator and the vendored mimalloc are statistically indistinguishable for `git repack -adfq` here. `windows-latest` runners are noisier (per-run variance ~1-4%, mostly neighbour-VM scheduling), but mimalloc never beats vanilla in either workload. With the original justification for keeping a custom allocator gone (the modern Windows segment-heap is no longer the slow Windows-XP-era `HeapAlloc` that drove the original 2009 nedmalloc adoption), there is nothing left to motivate the maintenance cost of a vendored allocator. `macos-latest` is too noisy at n=5 (stdev 14% of the mean) to draw a firm conclusion, but the visible point-estimate goes the wrong way and there is no plausible mechanism by which Apple's `libsystem_malloc` would be slower than mimalloc. ## What this PR does *not* do It does not by itself remove `nedmalloc` from the tree; that is still promised as a follow-up of the in-flight upstream patch gitgitgadget#2104, presently in `seen` as e576abb. The first commit here is an `amend!` whose autosquashed result is byte-identical to that upstream commit, so once the next merging-rebase picks up the upstream patch the two will collapse cleanly. The five remaining `fixup!` reverts target each of the original mimalloc-vendoring commits in reverse chronological order; once autosquashed, the pairs cancel out to empty commits which the rebase will drop, leaving the tree free of `compat/mimalloc/`, the `USE_MIMALLOC` build infrastructure, and the supporting changes (`compat/posix.h` `_DEFAULT_SOURCE` guard, `win32_pthread_*` renames) that only existed to support the vendored allocator.
2 parents 0bbe6df + d6fdcfb commit 47b4b08

37 files changed

Lines changed: 7 additions & 16758 deletions

Makefile

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,6 @@ BUILTIN_OBJS += builtin/write-tree.o
15211521
# upstream unnecessarily (making merging in future changes easier).
15221522
THIRD_PARTY_SOURCES += compat/inet_ntop.c
15231523
THIRD_PARTY_SOURCES += compat/inet_pton.c
1524-
THIRD_PARTY_SOURCES += compat/mimalloc/%
15251524
THIRD_PARTY_SOURCES += compat/nedmalloc/%
15261525
THIRD_PARTY_SOURCES += compat/obstack.%
15271526
THIRD_PARTY_SOURCES += compat/poll/%
@@ -2299,47 +2298,6 @@ ifdef USE_NED_ALLOCATOR
22992298
OVERRIDE_STRDUP = YesPlease
23002299
endif
23012300

2302-
ifdef USE_MIMALLOC
2303-
MIMALLOC_OBJS = \
2304-
compat/mimalloc/alloc-aligned.o \
2305-
compat/mimalloc/alloc.o \
2306-
compat/mimalloc/arena.o \
2307-
compat/mimalloc/bitmap.o \
2308-
compat/mimalloc/heap.o \
2309-
compat/mimalloc/init.o \
2310-
compat/mimalloc/libc.o \
2311-
compat/mimalloc/options.o \
2312-
compat/mimalloc/os.o \
2313-
compat/mimalloc/page.o \
2314-
compat/mimalloc/random.o \
2315-
compat/mimalloc/prim/prim.o \
2316-
compat/mimalloc/segment.o \
2317-
compat/mimalloc/segment-map.o \
2318-
compat/mimalloc/stats.o
2319-
2320-
COMPAT_CFLAGS += -Icompat/mimalloc -DMI_DEBUG=0 -DUSE_MIMALLOC --std=gnu11
2321-
COMPAT_OBJS += $(MIMALLOC_OBJS)
2322-
2323-
$(MIMALLOC_OBJS): COMPAT_CFLAGS += -DBANNED_H
2324-
2325-
$(MIMALLOC_OBJS): COMPAT_CFLAGS += \
2326-
-DMI_WIN_USE_FLS \
2327-
-Wno-attributes \
2328-
-Wno-unknown-pragmas \
2329-
-Wno-unused-function \
2330-
-Wno-array-bounds
2331-
2332-
ifdef DEVELOPER
2333-
$(MIMALLOC_OBJS): COMPAT_CFLAGS += \
2334-
-Wno-pedantic \
2335-
-Wno-declaration-after-statement \
2336-
-Wno-old-style-definition \
2337-
-Wno-missing-prototypes \
2338-
-Wno-implicit-function-declaration
2339-
endif
2340-
endif
2341-
2342-
23432301
ifdef OVERRIDE_STRDUP
23442302
COMPAT_CFLAGS += -DOVERRIDE_STRDUP
23452303
COMPAT_OBJS += compat/strdup.o

compat/.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
/zlib-uncompress2.c whitespace=-indent-with-non-tab,-trailing-space
2-
/mimalloc/**/* whitespace=-trailing-space

compat/mimalloc/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)