Hacker News new | ask | show | jobs
by bastawhiz 3494 days ago
It's worth noting that the compiler does more than just make things fast. Even the smartest of people muck up things like keeping track of types and doing pointer math every now and then. Let's say you managed the OpenSSL project. If you knew, statistically, that every line of hand-written assembly reduced runtime by Y percent and increased the likelihood of a heartbleed-magnitude security issue (caused by that code) by Z percent, how much Y would you trade for Z?

If the compiler even averages out with a human with performance, the ability to get the sort of messages that, say, rustc generates is utterly invaluable.

1 comments

OpenSSL uses assembly not for speed but for security. You need to make sure algorithms don't "optimize" leaking data.

For example, a strcmp on a secret field is insecure because of timing attacks.

The only way to ensure the CPU takes a fixed amount of time is through assembler

That also brings about the risk of doing bad things that the compiler could otherwise prevent. Simply using a non-optimizing compiler with a timing attack-safe algorithm (and using the resulting machine code) would have the same effect. There's little reason to actually write assembly by hand, in that case, unless you're trying to milk performance.