News for hackers. Stuff that matters.
Re:Make Ubuntu packages 90% faster by rebuilding them by taeric on Tuesday March 18, 2025 @08:07PM (#43406798)
Surprised it would be 90%. Are the packages all debug symbols?

I recall trying with march=native and seeing some improvement, but not enough to care at a system level.

Re:Make Ubuntu packages 90% faster by rebuilding them by jeffbee on Tuesday March 18, 2025 @08:12PM (#43406836)
> Are the packages all debug symbols?

Upstream is stripped actually. My final build here is 43x larger than the distro binary, partly due to having plentiful debug info.

Re:Make Ubuntu packages 90% faster by rebuilding them by taeric on Tuesday March 18, 2025 @08:33PM (#43407006)
Sorry, I didn't mean symbols, I meant optimization level. Hilarious that they have symbols stripped, but still outclassed.

Love to see why they wouldn't have more optimizations.

I'm assuming this isn't the case for more packages? Feels too good.

Re:Make Ubuntu packages 90% faster by rebuilding them by wongarsu on Tuesday March 18, 2025 @09:25PM (#43407375)
Ubuntu is still building for CPUs with the x86-64-v1 feature set. On experimental images built for x86-64-v3 (roughly the feature set of 10 year old CPUs, a bit newer on low-power CPUs) they have observed 60% improvement on some benchmarks (and much less in some others). Some distros have switched to -v3, Ubuntu is still holding out to support older hardware. The author is compiling to the actual feature set of their specific CPU, which is nearly guaranteed to be even more than -v3.

Another thing the article adds is LTO, which in my experience also makes a huge difference: it makes your software a lot faster in certain cases, but also makes build times a lot worse. Spending a bit more time in the build process should be an easy call, but might be harder at the scale of a distro.

Re:Make Ubuntu packages 90% faster by rebuilding them by taeric on Wednesday March 19, 2025 @12:08AM (#43408198)
I was under the, evidently naive, understanding that there were some shenanigans done in the libc to pick optimal code paths based on the architecture. This would obviously have a startup cost on the first run, but presumably the dynamic linking would work to this advantage by having it in a fast state for most calls?

Not sure where I got that idea, though. :(. Will have to look into that later.

Re:Make Ubuntu packages 90% faster by rebuilding them by vlovich123 on Wednesday March 19, 2025 @01:07AM (#43408424)
Even if libc does it, other packages wouldn’t. The compiler is what generates code and they generally don’t try to automatically generate for different instruction sets because they don’t know what code is what hotpath and worth optimizing for. You could probably try to build for multiple different CPU features at the top level and do a universal executable like Apple did for their CPU transitions but that’s a lot of expense to pay both in terms of compilation time AND in terms of size.
Re:Make Ubuntu packages 90% faster by rebuilding them by dan-robertson on Tuesday March 18, 2025 @09:01PM (#43407212)
Debug symbols do not need to be paged in so shouldn’t make much/any difference. Compiling with -O3 can increase code size a lot due to inlining, which can be a little bad.
Re:Make Ubuntu packages 90% faster by rebuilding them by taeric on Wednesday March 19, 2025 @12:12AM (#43408212)
Right, my humor there was that I'm assuming people specifically did non-debug flags for the build as an optimization. Only for them to still fall short.

And understood a little on -O3 possibly increasing code size. I had thought that was more of a concern for tight environments than for most systems? Of course, I'd have assumed that -march=native would be more impactful, but the post indicates otherwise.

I said in a top level, but it seems the allocator makes the biggest impact for this application? Would be interesting to see which applications should use different allocators. Would be amazing to see a system where the more likely optimal allocator was default for different applications, based on their typical allocation patterns.

Re:Make Ubuntu packages 90% faster by rebuilding them by turol on Wednesday March 19, 2025 @03:04AM (#43408989)
> Right, my humor there was that I'm assuming people specifically did non-debug flags for the build as an optimization.

It used to be the case that the presence of debug symbols would affect GCC code generation. Nowadays that should be fixed. I think it still affects the speed of compilation so if you're building the whole system from source you might want to avoid it.

Re:Make Ubuntu packages 90% faster by rebuilding them by SkiFire13 on Wednesday March 19, 2025 @08:06AM (#43410831)
> And understood a little on -O3 possibly increasing code size. I had thought that was more of a concern for tight environments than for most systems?

Increasing code size too much can result in hot functions not fitting in the icache, and that ultimately can make your program slower.

Re:Make Ubuntu packages 90% faster by rebuilding them by pests on Tuesday March 18, 2025 @11:58PM (#43408162)
Mario 64 gets flak for some files not being compiled with optimizations on. There is a YouTuber, whose name I forget at the moment, who has been doing optimization and improvements on it and constantly talks about how this is for the better due to the low instruction cache size and slow speed on the console. Compiling with optimizations explodes code size (unrolling links, inlining, etc) to the point it’s a net loss after factoring in the increased load on the IC.
Re:Make Ubuntu packages 90% faster by rebuilding them by chasil on Wednesday March 19, 2025 @04:52AM (#43409588)
The -Os flag optimizes for size.

What impact does that have?

Re:Make Ubuntu packages 90% faster by rebuilding them by rurban on Wednesday March 19, 2025 @09:21AM (#43411594)
The IC is the instruction cache. Bloated code needs more slow loads from the IC, and even if the performance is faster per cache line, the 50x overhead of added cache loads diminishes all -O3 advantages.
Re:Make Ubuntu packages 90% faster by rebuilding them by tjalfi on Wednesday March 19, 2025 @02:54PM (#43415959)
Kaze Emanuar[0] is the YouTuber you're thinking of.

[0] https://www.youtube.com/@KazeN64

Re:Make Ubuntu packages 90% faster by rebuilding them by pests on Thursday March 20, 2025 @01:28PM (#43426182)
Yes thank you!
Re:Make Ubuntu packages 90% faster by rebuilding them by AceJohnny2 on Tuesday March 18, 2025 @09:20PM (#43407348)
> Hilarious that they have symbols stripped, but still outclassed.

Debug symbols have 0 runtime penalty, just storage. They're just another section of the binary, referenced by debuggers, and which the loader skips.

In any case, all distros break out the symbols into separate files so that they can have their (storage) cake and (debug) eat it too.

Re:Make Ubuntu packages 90% faster by rebuilding them by taeric on Wednesday March 19, 2025 @12:06AM (#43408193)
Right, I meant the humor to be that folks to not use debug flags, with my naive presumption that they did this as an optimization, only for that not to really help.
Re:Make Ubuntu packages 90% faster by rebuilding them by kazinator on Tuesday March 18, 2025 @09:19PM (#43407340)
Using preload on the stock Ubuntu binary, to give it mimalloc, they got a 44% speedup.

By rebuilding the binary with different compiler options, but not changing malloc, they got an 20% speedup.

If we naively multiply these speedups, we get 1.78: 78% faster.

How it goes to 1.9 is that when you speed up only the program, but leave malloc the same, malloc matters to its performance a lot more.

When the faster malloc is applied to a program that is compiled better, it will make a better contribution than the 44% seen when the allocator was preloaded into the slower program.

To do the math right, we would have to look into how much time was saved with just the one change, and how much time was saved with the other. If we add those times, and subtract them from the original, slow time, we should get a time that is close to the 1.9 speedup.

Original time: 4.631

Better compiler options alone: 3.853 (-0.778)

Better allocator alone (preload): 3.209 (-1.422)

Add time saved from both: 2.200

Projected time: 4.631 - 2.200 = 2.431

Projected speedup from both: 4.631/2.431 = 1.905

Bang on!

Re:Make Ubuntu packages 90% faster by rebuilding them by kazinator on Tuesday March 18, 2025 @09:25PM (#43407374)
This is the same reason why a faster garbage collector makes a huge difference to compiled code compared to interpreted.

When an AST interpreted languages gets a VM, gets native code, each step reveals GC to be slow.

You might go from 1% time spent in the GC to 15% to 60% (numbers of out thin air).

Re:Make Ubuntu packages 90% faster by rebuilding them by biohazard2 on Wednesday March 19, 2025 @06:41AM (#43410278)
It's not a 90% speedup, it's ~50% (still quite impressive). The author seems to be confused, because the original jq is 1.9x slower than the optimized one.
Re:Make Ubuntu packages 90% faster by rebuilding them by drakythe on Wednesday March 19, 2025 @10:31AM (#43412511)
That depends on how you're representing the speedup.

To travel 10 miles, at 60 MPH, takes 10 minutes. Make it 100% faster, at 120 MPH, and that time becomes 5 minutes. Travel just as far in 50% of the time. Or travel just as far 100% faster. The 90% speedup matches the reduction of the time it takes to nearly half (a 90% (projected) speedup, or about a 45% time reduction, as mathed out by kazinator `Projected speedup from both: 4.631/2.431 = 1.905`). Your claim that its closer to 50% is correct from a total time taken perspective, just coming at it from the other direction.