News for hackers. Stuff that matters.
Re:Moving the Linux Kernel to Modern C by pcwalton on Thursday February 24, 2022 @04:19PM (#30460442)
The advantages of using a newer language greatly outweigh the disadvantages of theoretical "reflections on trusting trust" attacks. By mandating C89, you're condemning thousands of kernel developers to use a language that's over 30 years old because of a theoretical attack that has never happened and seems practically implausible. Does anyone really think there's a backdoor in both GCC and Clang (remember, Linux can be compiled on either)?
Re:Moving the Linux Kernel to Modern C by gmadsen on Thursday February 24, 2022 @04:30PM (#30460575)
I am ignorant on nearly all compiler related issues, but there was an article on here not too long ago that was arguing that nearly all os development required old C because choices of the committee would break use cases required under the guise of undefined behavior.

is the benefits of "modern C" worth compile times 2-3x times longer?

Re:Moving the Linux Kernel to Modern C by pcwalton on Thursday February 24, 2022 @04:43PM (#30460725)
Times like these I wish I were allowed to say exactly how much money big companies save by using the newest versions of GCC and Clang. The economic value of modern compiler optimizations is staggering.
Re:Moving the Linux Kernel to Modern C by tomcam on Thursday February 24, 2022 @05:35PM (#30461276)
I hereby give you permission to say exactly how much money big companies save by using the newest versions of GCC and Clang.
Re:Moving the Linux Kernel to Modern C by pcwalton on Thursday February 24, 2022 @07:37PM (#30462352)
Thanks, but it's my employer's permission I'm concerned with. :)
Re:Moving the Linux Kernel to Modern C by bch on Thursday February 24, 2022 @04:55PM (#30460840)
> wish I were allowed to say exactly how much money big companies save[...]

Are you able to give hints that would guide us in thought exercises?

Re:Moving the Linux Kernel to Modern C by bluGill on Thursday February 24, 2022 @05:27PM (#30461201)
Facebook has hinted that they employ smart C++ people because some core optimizations can save on the order of several hundred thousand dollars per year (possibly in the millions). Most of that is off because they don't have to buy as much power to cool the server rooms, some of it is buying less servers as what they have can do more. Facebook doesn't actually say what they save, but they have said they measure it, and we know how much it costs to employ an engineer full time working only on optimization, and we know who some of those engineers are.

You have to be very large to notice it, but the likes of Facebook, amazon, and Google have massive warehouses almost entirely filled with computers. It doesn't take much to see how their power bill can add up.

Re:Moving the Linux Kernel to Modern C by plorkyeran on Thursday February 24, 2022 @06:16PM (#30461667)
Years ago Alexandrescu said that Facebook estimated a .1% speedup to HHVM would save them $100k/year. It's presumably only gone up since then, but he's stopped giving an actual number in talks.
Re:Moving the Linux Kernel to Modern C by ForOldHack on Saturday February 26, 2022 @03:53AM (#30476179)
I would argue that he is bragging, and that the amount of code optimization is minimal. Large companies love to brag about how many servers they have, and optimizing compilation is just a buzz word. Go ahead, buy another servers. $100k is nothing. Its less than 1 engineer year vs 24,000 engineer years.

The Distribution collectors, they brag about speed, and optimization is very important to them. They want to be able to test changes very quickly.

Re:Moving the Linux Kernel to Modern C by steveklabnik on Thursday February 24, 2022 @05:46PM (#30461409)
The parent works at Facebook/Meta leading their Rust team, focusing on compiler and ecosystem improvements. So that in and of itself is a sort of hint into what that info could be like, even if it's not actual details of the order of magnitude or anything.
Re:Moving the Linux Kernel to Modern C by ______-_-______ on Thursday February 24, 2022 @06:02PM (#30461547)
The Google Search optimization team measures changes in terms of millions of CPUs. So if upgrading your compiler saves even 0.1%, well, that's a lot of servers you don't have to buy next year.
Re:Moving the Linux Kernel to Modern C by ForOldHack on Sunday February 27, 2022 @04:52AM (#30486813)
Apple went out and bought a CRAY.

"Jun 30, 1987 — The Cray is part of a $20m installation used by Apple's Advanced Technology group and consists of four CPUs operating at 9.5nS per cycle,"

Now we have distcc, that can both massively parallelize compilation, and optimization.

Googles team probably shows some slight improvement, just to justify their work, but in the long run, its just as sloppy as industry wide coding is.

Microsoft is the absolute worst, along with Apple.

Re:Moving the Linux Kernel to Modern C by pertymcpert on Thursday February 24, 2022 @05:08PM (#30460949)
One avenue is to think about it in terms of datacenter compute. If modern compiler optimizations improve performance by 10%, aggregate the perf improvements across the entire world's compute and you get a huge saving.
Re:Moving the Linux Kernel to Modern C by aw1621107 on Thursday February 24, 2022 @05:10PM (#30460980)
> but there was an article on here not too long ago that was arguing that nearly all os development required old C because choices of the committee would break use cases required under the guise of undefined behavior.

I would guess that you're referring to either "How ISO C became unusable for operating systems development" ([0]) or "How One Word Broke C" ([1]).

[0]: https://arxiv.org/abs/2201.07845 , most recent HN discussion at https://news.ycombinator.com/item?id=30022022

[1]: https://web.archive.org/web/20210307213745/https://news.quel... , HN discussion at https://news.ycombinator.com/item?id=22589657

Re:Moving the Linux Kernel to Modern C by mananaysiempre on Thursday February 24, 2022 @05:15PM (#30461042)
Most of the really annoying UB is technically in C89 though, it’s just that compilers haven’t really treated it with such contempt for the first two decades or so. I can’t even recall any new kinds of (non-library) UB in C99 or C11 (though there have to be some).

So “old C” in such a case would need to mean “an old C implementation” (or possibly a new one, but simple or configured to behave like an old one), something like GCC 2.8 maybe, and nobody’s using that on desktop. So the language standard version should be mostly immaterial, and it’s not like the C89-to-C17 difference is anything like the yawning C++98-to-C++20 chasm. (This is a carefully phrased statement: C99 had complex numbers, which are annoying, and variable-length arrays, which are a significant change, but C11 demoted both to optional features.)

Re:Moving the Linux Kernel to Modern C by neysofu on Thursday February 24, 2022 @05:01PM (#30460895)
> is the benefits of "modern C" worth compile times 2-3x times longer?

I mean, you get more security by default and security is pretty darn important for kernels...

Re:Moving the Linux Kernel to Modern C by dataangel on Thursday February 24, 2022 @10:20PM (#30463375)
I think you're mixing up two different things. Newer standard versus newer compiler. All versions of the C standard have lots of undefined behavior. Newer compilers contain optimizers that are just better at leveraging it.
Re:Moving the Linux Kernel to Modern C by bonzini on Thursday February 24, 2022 @04:45PM (#30460744)
Why would a different standard cause longer compile times?
Re:Moving the Linux Kernel to Modern C by db48x on Friday February 25, 2022 @02:55AM (#30464711)
If the spec requires that the compiler look for a certain error and produce a diagnostic, then the compiler has to spend time doing that. The more complicated the spec is, the more work the compiler has to do to find the errors.

For example, Rust is frequently said to have long compile times. There are a number of interesting reasons why that is often true, but if we ignore the pathological cases then what we find is that borrow checking takes a significant fraction of that compile time. This is a big trade–off between features and complexity that the Rust language made very deliberately: the advantages of the borrowing rules are what makes Rust such a great language. The cpu time spent checking that those rules have been followed are a small price to pay, but not a negligible one.

Re:Moving the Linux Kernel to Modern C by midjji on Friday February 25, 2022 @03:17PM (#30471864)
Is there a single such which you cannot disable by compiler flags?
Re:Moving the Linux Kernel to Modern C by db48x on Saturday February 26, 2022 @12:21AM (#30475381)
You cannot disable the borrow checker in Rust with a compiler flag. You might as well try to turn off the type checker, or ask it to ignore syntax errors.