|
|
Subscribe / Log in / New account

A lot of good stuff in there

A lot of good stuff in there

Posted Feb 16, 2025 13:37 UTC (Sun) by pizza (subscriber, #46)
In reply to: A lot of good stuff in there by khim
Parent article: New leadership for Asahi Linux

> That's where the source of the drama lies – and explains why Linux maintainers are almost all “old guys” who started worked with Linux decades ago… new generations wants to “throw away” precisely these things that “old guys” find valuable and important!

I think you hit the hail on the head, thank you for writing all that up.

But over the course of my career, I've noticed that fewer and fewer (both proportionally and in absolute terms) know or even care about how the hardware actually works. Not just to make things work well/fast, but to be able to *debug* what's going on should something inevitably go wrong.

Even thirty years ago, these skills and interest were relatively rare, but today they're actively dumped on even as they're depended upon more than ever. Core infrastructure isn't sexy, but necessary -- It's the "I don't care about the plight of farmers, I get my food from the supermarket" attitude all over again,


to post comments

A lot of good stuff in there

Posted Feb 16, 2025 14:12 UTC (Sun) by khim (subscriber, #9252) [Link] (3 responses)

> I've noticed that fewer and fewer (both proportionally and in absolute terms) know or even care about how the hardware actually works.

It's definitely true about “proportionally”, but I'm not sure it's true for “absolute terms”. There are enough people who want to know how the hardware actually works – or we wouldn't be getting so many emulators on /r/rust.

We had no trouble of finding students who wanted to poke with bytecode and machine code generation for internship, that's for sure!

They just don't want to think and worry about “how the hardware actually works” in every line of code they write!

> Not just to make things work well/fast, but to be able to *debug* what's going on should something inevitably go wrong.

But isn't it the same with other human endeavors? Once upon time every car driver was a car mechanic, too. And early plane pilots were sure plane without open cockpit wouldn't ever work because one have “feel” air to successfully maneuver the plane!

Today… there are still car mechanics and car designers and people who know how to build planes exist, still… but most drivers and pilots don't really care about “how all that actually works”.

Why should software development be any different?

> Core infrastructure isn't sexy, but necessary -- It's the "I don't care about the plight of farmers, I get my food from the supermarket" attitude all over again

True. That describes the majority. But the trouble for Linux (and for “old timers”, in general) comes from the other direction: It's one thing to “lift the lid” and understand what is happening when your program suddenly becomes 20x slower for no good reason (just a very recent experience when bad interaction of SSE and AVX caused us precisely that… we certainly needed to poke in the generated code to see what exactly have changed and what exactly makes everything so slow… filled the bug for the clang, too… it should be included in version 21 – and that was done by former students) – and completely different thing to write every line of code with full understanding of what would it produce on the machine code level.

First one is fun and interesting and important… second one… no one from “new generations” want to do that! Every time someone like wtarreau asks “how am I supposed to translate this machine code to Rust” the answer is always “well, there's unsafe and intrinsics and asm and other such tools for these exotic cases where that's needed”… they entirely miss the point that wtarreau brings about how someone may want to know that in every piece of code that one writes!

But, ultimately, Rust guys are right: writing code in way that you may always tell what precisely is generated from this or that line of source code was natural when compilers were extremely dumb and computers were extremely slow… today, even if code generated is not always the best… does it really matter if we don't have enough people to write anything else? Even the ones who do care about the machine code generated naturally assume that work of writing correct code and work of looking on what is happening on machine code level are separate works, you don't do them simultaneously!

A lot of good stuff in there

Posted Feb 16, 2025 20:27 UTC (Sun) by wtarreau (subscriber, #51152) [Link] (2 responses)

I think you nailed the whole thing right, khim.

And it's true that as time passes and machines improve, some older optimizations are no longer relevant. For example I took extreme care to avoid generating bsf/bsr on atoms because that was slow as hell while a hand-written version was much faster, to the point of being visible in the end-user's code. Nowadays first-gen atoms have disappeared and that distinction can disappear as well. Similarly, there's a lot of legacy code around to deal with each generation of compiler's misbehavior, like gcc 4.x doing stupidities with __builtin_expect(x, 1) that was turning x to an int and explicitly comparing it to value 1! Some of the complexity of old code does come from the collection of all such bad stuff, and many of us have been happy to fix such performance trouble caused by a single stupidity in a compiler or CPU that was causing 2-3% total performance loss. And code cleanups over time allow to get rid of that stuff, which sometimes can look like pieces of art, by the way, but just no longer relevant art.

Some of us know that such problems are recurring and continue to want to be able to provide solutions to them. Nowadays, with massively multi-core CPUs we're seeing extreme times caused by cache line sharing that happens very easily if you're not careful. I've been used to organize my structs to avoid accidental sharing between areas that are supposed to be accessible from other threads and those which don't for example. And that's just an example. Sometimes you realize that a function call significantly degrades performance just because pushing the return pointer to the stack forces cache writes because in parallel you're holding a lock that another CPU tries to acquire, and since that lock is in the same cache line as the data you're manipulating, every time it wants to read the lock's state, it causes a cache line flush which due to TSO also causes the stack to be written. I'd feel terribly useless by not being able to easily tweak all that when such problems are faced.

And at the same time I totally understand that the vast majority of developers don't want to care about this. A lot of code doesn't need to be finely tuned nor to be performant under specially stressful conditions. But what I like in programming precisely is getting the most from the hardware and making sure my code scales as much as possible. Just for the same reason I wouldn't develop a web browser in C myself and would rather have someone do it in a more suitable language, there would probably be specific points where that person would prefer to rely on low-level optimizations for certain things that are on the critical path and rely on someone doing my job in their preferred language. I think there are jobs for everyone, and when all developers will realize that this should be complementary instead of a competition, we'll have made great progress!

A lot of good stuff in there

Posted Feb 17, 2025 12:58 UTC (Mon) by taladar (subscriber, #68407) [Link] (1 responses)

If you enjoy that sort of micro-optimization, could you maybe scratch that itch by providing tooling that detects those situations or writing compiler code that avoids them/optimizes them instead of writing code manually that does all those things? Or would you consider that less enjoyable?

A lot of good stuff in there

Posted Feb 17, 2025 19:40 UTC (Mon) by wtarreau (subscriber, #51152) [Link]

> If you enjoy that sort of micro-optimization, could you maybe scratch that itch by providing tooling (...)

There's no single rule for this, everyone has their own methods and intuitions depending on what they see, and based on their experience. There's no magic, it's just called "development". Tools to help for this already exist and are overly used. "perf" is one of them, there's a reason it by defaults shows the instructions where you're spending time and also delivers hardware performance counters to figure if you're waiting for data too often etc, and such tools users expect to retrofit changes in their code to change the machine code's behavior and the execution pattern. It's not uncommon to achieve multiple unit gains on a whole program's performance using perf, when you're facing a scalability issue.

Another very popular tool is godbolt.org. Similarly, it shows you the resulting asm for your code, and allows you to try many compiler flavors, versions and architectures to verify if your workaround for a limitation is portable enough. It's precisely because a lot of developers care about this that such tools exist and are popular.

The C language is quite terrible for many reasons, and C compilers are particularly stubborn and will to everything they can not to help you. However once you've figured that instead you are the one supposed to help them to produce better code by giving them some hints about what you're trying to do, they appear to show quite reproducible behaviors, with worst case being optimizations that just degrade to the default case. In this situation it's often worth investing time to help them, including only on certain platforms if only certain permit some optimizations. The gains are sometimes high enough to reduce the number of machines in production, and at this point that starts to count.

A lot of good stuff in there

Posted Feb 16, 2025 15:54 UTC (Sun) by dralley (subscriber, #143766) [Link] (1 responses)

C is not "how the hardware actually works". Even assembly is not exactly "how the hardware actually works" (but it's a lot closer than C).

C represents a very simplified model of how *some* hardware works. There has also been a lot of convergent evolution such that hardware is designed to work in such a way that C works well with it, because C and C-like languages are so important.

A lot of good stuff in there

Posted Feb 16, 2025 17:33 UTC (Sun) by pizza (subscriber, #46) [Link]

> C is not "how the hardware actually works". Even assembly is not exactly "how the hardware actually works" (but it's a lot closer than C).

Please read and respond to what I actually wrote.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds