www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - 18% faster build time when using DMD with mimalloc!

reply ryuukk_ <ryuukk.dev gmail.com> writes:
Simply just compiling my project with that allocator makes it 18% 
faster

 From an average of 450ms down to 381ms, fastest was 374ms

```
$ hyperfine "make build-game" "make build-game-mimalloc"
Benchmark 1: make build-game
   Time (mean ± σ):     450.4 ms ±   4.6 ms    [User: 383.8 ms, 
System: 64.7 ms]
   Range (min … max):   443.9 ms … 458.9 ms    10 runs

Benchmark 2: make build-game-mimalloc
   Time (mean ± σ):     381.7 ms ±   6.7 ms    [User: 346.2 ms, 
System: 34.1 ms]
   Range (min … max):   374.7 ms … 393.4 ms    10 runs

Summary
   make build-game-mimalloc ran
     1.18 ± 0.02 times faster than make build-game
```

Try with your project, and share the result here, and perhaps we 
should make it the default if it's an improvement for everyone?


`LD_PRELOAD=/usr/lib/libmimalloc.so dmd`
Mar 26
next sibling parent ryuukk_ <ryuukk.dev gmail.com> writes:
I forgot to include the link of the project: 
https://github.com/microsoft/mimalloc/
Mar 26
prev sibling next sibling parent reply Johan <j j.nl> writes:
On Tuesday, 26 March 2024 at 15:56:14 UTC, ryuukk_ wrote:
 Try with your project, and share the result here, and perhaps 
 we should make it the default if it's an improvement for 
 everyone?
Yep, it's huge, definitely should be default for DMD releases. LDC releases are built with mimalloc since ~2years. -Johan
Mar 26
parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Tuesday, 26 March 2024 at 18:23:07 UTC, Johan wrote:
 On Tuesday, 26 March 2024 at 15:56:14 UTC, ryuukk_ wrote:
 Try with your project, and share the result here, and perhaps 
 we should make it the default if it's an improvement for 
 everyone?
Yep, it's huge, definitely should be default for DMD releases. LDC releases are built with mimalloc since ~2years. -Johan
Are you sure? i tried with LDC (1.37.0) and i get 2.3sec vs 2.0sec with LD_PRELOAD
Mar 26
parent reply Johan <j j.nl> writes:
On Tuesday, 26 March 2024 at 18:34:00 UTC, ryuukk_ wrote:
 On Tuesday, 26 March 2024 at 18:23:07 UTC, Johan wrote:
 On Tuesday, 26 March 2024 at 15:56:14 UTC, ryuukk_ wrote:
 Try with your project, and share the result here, and perhaps 
 we should make it the default if it's an improvement for 
 everyone?
Yep, it's huge, definitely should be default for DMD releases. LDC releases are built with mimalloc since ~2years. -Johan
Are you sure? i tried with LDC (1.37.0) and i get 2.3sec vs 2.0sec with LD_PRELOAD
Quite sure. https://github.com/ldc-developers/ldc/blob/3a6f2cae331c5a84a2f0dd2f6d6e9e09dbfad86d/.github/actions/3-build-native/action.yml#L26 You can check whether your LDC has mimalloc included by setting environment variable `MIMALLOC_SHOW_STATS=1` (shows statistics when the program terminates) Don't know why it'd be 10% faster in your case with LD_PRELOAD... -Johan
Mar 26
parent Steven Schveighoffer <schveiguy gmail.com> writes:
On Tuesday, 26 March 2024 at 18:46:59 UTC, Johan wrote:
 Don't know why it'd be 10% faster in your case with 
 LD_PRELOAD...
Perhaps this is affecting more than just LDC? Maybe the linker too? -Steve
Mar 27
prev sibling next sibling parent user <user tmp.com> writes:
On Tuesday, 26 March 2024 at 15:56:14 UTC, ryuukk_ wrote:
 Simply just compiling my project with that allocator makes it 
 18% faster
I always wondered why do people report SW improvements as increase in speed, instead of reduction in time. Its not like we are 'driving' a compiler and need to watch its speedometer, I am pretty sure everyone are watching a clock instead. After a bit of math, I realized that reporting the changes in "speed" always paints a more rosy picture than reporting the changes in time. For example, a 25% reduction in time will be reported as 33% increase in speed, where as a 25% increase in time will be reported as only 20% worsening of speed. Exaggeration is probably not the main reason. Or is it? *cue Vsause music* Just a fun fact I wanted to share :-)
Mar 26
prev sibling parent Dennis <dkorpel gmail.com> writes:
On Tuesday, 26 March 2024 at 15:56:14 UTC, ryuukk_ wrote:
 Try with your project, and share the result here, and perhaps 
 we should make it the default if it's an improvement for 
 everyone?
Thanks for sharing! I tested it on one of my applications, and build time went down from 0.44s to 0.35s. Building all my apps and running all my unittests went from 11.6s to 9.95s, which is amazing for how little effort it took (`sudo pacman -S mimalloc` and `export LD_PRELOAD=/usr/lib/libmimalloc.so`).
Mar 26