News for hackers. Stuff that matters.
Re:All About Libpas, Phil's Super Fast Malloc by pizlonator on Wednesday June 01, 2022 @11:05AM (#31582880)
I never got a chance to compare it to those, since I was most interested in beating bmalloc. And I mainly wanted to beat it on Safari workloads.

I believe bmalloc was previously compared against jemalloc and tcmalloc, also using Safari workloads, and bmalloc was significantly faster at the time.

Re:All About Libpas, Phil's Super Fast Malloc by IshKebab on Wednesday June 01, 2022 @01:36PM (#31585288)
For other people who have never heard of bmalloc - it's a custom allocator used only by WebKit. I guess it's not surprising they added one since the Mac system allocator is extremely slow. A custom allocator is pretty much a free 20% speed up on Mac (depending on your workload) but I found they made no difference on Linux. Haven't tried on Windows.
Re:All About Libpas, Phil's Super Fast Malloc by pizlonator on Wednesday June 01, 2022 @02:12PM (#31585807)
Just some credit where credit is due.

I measured the system malloc crushing all other mallocs on some workloads and they were the kind of workloads that some folks run every day.

I measured the system malloc crushing most other mallocs on memory efficiency on most workloads. System malloc is really good at reusing memory and has very mature decommit policies that easily rival what I came up with.

So there’s that.

Re:All About Libpas, Phil's Super Fast Malloc by meisel on Wednesday June 01, 2022 @04:05PM (#31587280)
What sort of workloads are those? I have yet to see a workload where macOS's system allocator is not substantially slower than alternatives like jemalloc.
Re:All About Libpas, Phil's Super Fast Malloc by pcwalton on Wednesday June 01, 2022 @05:18PM (#31588269)
macOS malloc was incredibly slow for Pathfinder, far behind every other OS. Everything became bottlenecked on it. It was a free 2x speedup if not more to switch to jemalloc.

I suspect this is because Pathfinder's CPU portion is a multicore workload and macOS allocator performs poorly when under heavy multithreaded contention. It probably just isn't the kind of workload that macOS allocator was tuned for.

Re:All About Libpas, Phil's Super Fast Malloc by pizlonator on Wednesday June 01, 2022 @05:24PM (#31588341)
My understanding is that the system malloc is excellent under contention, but has a high baseline cost for every malloc/free call.

I don't remember exactly what workloads it performed really great at (and if I did I dunno if I could say), but I do remember they were parallel, and the speed-ups got bigger the more cores you added.

Everything else about your experience matches mine. Libpas is much faster than system malloc in WebKit and JSC. The difference isn't 2x on my preferred benchmarks (which are large and do lots of things that don't rely on malloc), but it is easily more than 2x on smaller benchmarks. So your 2x result sounds about right.

Re:All About Libpas, Phil's Super Fast Malloc by astrange on Wednesday June 01, 2022 @02:31PM (#31586105)
Alas, many people think performance engineering is only about the wall clock time of their program and not what impact it has on anything else.

malloc performance highly depends on how large the allocations are though.

Re:All About Libpas, Phil's Super Fast Malloc by KerrAvon on Wednesday June 01, 2022 @03:23PM (#31586731)
What's the workload where you found that to be the case? The system allocator is heavily tuned for general use, and should be very difficult to beat -- generally.
Re:All About Libpas, Phil's Super Fast Malloc by IshKebab on Wednesday June 01, 2022 @04:50PM (#31587900)
It was a non-traditional compiler written in C++.

> The system allocator is heavily tuned

Perhaps but it probably has more constraints than a custom allocator too, e.g. backwards compatibility with software that unwittingly depends on its exact behaviour.

I found a discussion of this where people reported various speedups (10%, 100%, 300%) on Mac by switching to a custom allocator: https://news.ycombinator.com/item?id=29068828

I'm sure there are better benchmarks if you Google it.

Re:All About Libpas, Phil's Super Fast Malloc by kookamamie on Thursday June 02, 2022 @01:39AM (#31591722)
tcmalloc and mimalloc are the ones I'd be interested seeing comparisons to. The former is the fastest in my case, which is essentially many-core HPC.