Skip to content

Commit 52a9199

Browse files
dschoGit for Windows Build Agent
authored andcommitted
fixup! mimalloc: offer a build-time option to enable it
Re-running the `git repack -adfq` benchmark from 6a29c2d ("mingw: use mimalloc", 2019-06-24) against the platform's *current* default allocator (so without `nedmalloc` in the picture at all) shows mimalloc is no longer faster than the system allocator on any of Windows, macOS, or Linux, neither for the original ~30-second `linux v2.6.20` workload nor for a 4x larger `linux v3.0` workload where each individual run takes ~2 minutes (and the noise floor on Linux is below 0.3% of the mean, so even small differences would be visible if any existed). `mimalloc` was originally chosen over nedmalloc, not over the system allocator. Six years on, with nedmalloc now being dropped from the codebase entirely, the allocator that mimalloc has to beat is whatever the OS ships by default; modern Windows segment-heap, glibc malloc, and the macOS libsystem allocator have all closed the gap, and there is no longer a measurable benefit to keep maintaining a custom allocator. The actual benchmark methodology, the per-platform numbers, and links to the workflow runs that produced them are spelled out in the PR description rather than repeated across each fixup. The `fixup!` subject is so that the next rebase against an upstream Git that already lacks this commit will autosquash this revert into the original (which becomes empty and is dropped), leaving the tree free of `mimalloc`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 0025b12 commit 52a9199

5 files changed

Lines changed: 1 addition & 56 deletions

File tree

Makefile

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,6 @@ BUILTIN_OBJS += builtin/write-tree.o
15191519
# upstream unnecessarily (making merging in future changes easier).
15201520
THIRD_PARTY_SOURCES += compat/inet_ntop.c
15211521
THIRD_PARTY_SOURCES += compat/inet_pton.c
1522-
THIRD_PARTY_SOURCES += compat/mimalloc/%
15231522
THIRD_PARTY_SOURCES += compat/nedmalloc/%
15241523
THIRD_PARTY_SOURCES += compat/obstack.%
15251524
THIRD_PARTY_SOURCES += compat/poll/%
@@ -2297,47 +2296,6 @@ ifdef USE_NED_ALLOCATOR
22972296
OVERRIDE_STRDUP = YesPlease
22982297
endif
22992298

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,6 @@ typedef unsigned long uintptr_t;
176176
#define _ALL_SOURCE 1
177177
#endif
178178

179-
#ifdef USE_MIMALLOC
180-
#include "mimalloc.h"
181-
#define malloc mi_malloc
182-
#define calloc mi_calloc
183-
#define realloc mi_realloc
184-
#define free mi_free
185-
#define strdup mi_strdup
186-
#define strndup mi_strndup
187-
#endif
188-
189179
#ifdef MKDIR_WO_TRAILING_SLASH
190180
#define mkdir(a,b) compat_mkdir_wo_trailing_slash((a),(b))
191181
int compat_mkdir_wo_trailing_slash(const char*, mode_t);

config.mak.dev

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ endif
2222

2323
ifneq ($(uname_S),FreeBSD)
2424
ifneq ($(filter gcc6,$(COMPILER_FEATURES)),)
25-
ifndef USE_MIMALLOC
2625
DEVELOPER_CFLAGS += -std=gnu99
2726
endif
28-
endif
2927
else
3028
# FreeBSD cannot limit to C99 because its system headers unconditionally
3129
# rely on C11 features.

config.mak.uname

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ endif
515515
CC = compat/vcbuild/scripts/clink.pl
516516
AR = compat/vcbuild/scripts/lib.pl
517517
CFLAGS =
518-
BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -MP -std:c11
518+
BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
519519
COMPAT_OBJS = compat/msvc.o compat/winansi.o \
520520
compat/win32/flush.o \
521521
compat/win32/path-utils.o \

0 commit comments

Comments
 (0)