4 ms·
From that argument, we should be coding everything in hand tuned assembly, because hand tuned assembly gives a 10% to 200% speedup over C. The number one slowd
by bb88 8y ago
From that argument, we should be coding everything in hand tuned assembly, because hand tuned assembly gives a 10% to 200% speedup over C.
The number one slowdown I've seen in rendering web pages, were not bad algorithms or bad programming languages, but bad database queries.
And if that's the case, there is a lot more optimization in the DB to be gained than rewriting your back-end to C, say.
- pcwalton 8y ago> From that argument, we should be coding everything in hand tuned assembly, because hand tuned assembly gives a 10% to 200% speedup over C. Yes, all things equal, it's better to write faster CPU-bound code. In a world in which writing optimal machine code all the time was possible without sacrificing anything else important, then we would always want to do it. This is hardly a controversial conclusion. The reason we don't write faster CPU-bound code is that, in the world we live in, all things are never equal. Correctness, security, maintainability, development velocity, portability, engineering culture/trends, and so on are usually more important than raw CPU performance.
- kragen 8y agoThis was true in 1995, assuming you can spend unlimited time writing your code. You can almost certainly get an order of magnitude better performance with a custom backend written in a low-level language instead of a SQL database. And, I don't know if you've ever used a SQL database written in Python instead of C, but I have, and it's definitely a lot slower. But it's not true today, because today hand-tuned assembly is slow compared to what you can do on the GPU or an FPGA or a TPU. And, of course, it's not true that you should do this if you can't spend unlimited time writing your code. It's entirely reasonable to use slower languages like Python and JS if you can hack faster as a result. Since many of us are taking that entirely reasonable option, the number of CPU cycles needed to run basic applications is going up, which increases power consumption.
- littlestymaar 8y ago> But it's not true today, because today hand-tuned assembly is slow compared to what you can do on the GPU or an FPGA or a TPU. That's not how thing work. GPUs/TPUs aren't magic, they don't speed everything up: they are really good is some scenario, but they are really slow in many others: the cost of loading memory to the GPU and back from it has a huge cost and it's only worth it if the GPU has enough work to do with the workload. In theory, you could write a web server that runs on the GPU (at least a majority of it, it will still need some CPU work obviously), but it would be incredibly slow, probably slower than if it was a regular web server running on a machine from the 90s. FPGA are totally different beasts, you can theoretically speed up anything with them, but 1. that requires a LOT of work, and 2. they aren't new: anything you can do with FPGA today, you could do it in 1995 already.
- bb88 8y ago> And, I don't know if you've ever used a SQL database written in Python instead of C, but I have, and it's definitely a lot slower. I don't doubt that but on today's web stacks you use either MySQL or Postgres typically and both those are written in C. Yes, you can create your own DB written in a low level language, but you'll be hitting the same issues that the DB solves for you (indexing upon insertions, query optimizations, transactional operations, etc).