r/cpp • • Feb 16 '26

Favorite optimizations ??

I'd love to hear stories about people's best feats of optimization, or something small you are able to use often!

136 Upvotes

185 comments sorted by

View all comments

Show parent comment

7

u/lordnacho666 Feb 16 '26

Yeah, simply using any allocator other than the default one does wonders.

2

u/Both_Helicopter_1834 Feb 16 '26

To me, that doesn't seem obviously true in general. Can you elaborate?

1

u/lordnacho666 Feb 16 '26

Let me see if I can find an old SO question. (Yes I know they're all old lol)

1

u/Fabulous-Meaning-966 Feb 19 '26

Depends on your baseline. This is often true for the glibc allocator in Linux, less so for the default libc allocator in FreeBSD (jemalloc).

1

u/lordnacho666 Feb 19 '26

That's a fair point actually