How much your computer can do in a second
71–80 of 244 posts
Re: How much your computer can do in a second
#72Earlier quoted context omitted.
To be fair, that article is discussing a small bug, not over engineering or dogma. The size of the deal people made over it was more wasteful than the CPU time this (now fixed) bug cost. And FWIW, of all the problems that matter to me and my teams, I find premature optimization to be far, far more wasteful of money and human energy than wasted CPU cycles. There are definitely times to worry about performance, and I f…
Its always about making the right judgement call between optimization and complexity, and sometimes I'm still surprised by what needs optimized and what doesn't. An anecdote from a project I'm working on. I'm writing some LED control software for light shows and using GPIO pins on various embedded Linux boards (CHiP, Raspberry Pi, Orange Pi) to generate the SPIO-like serial signal I need. My first draft, for Raspberr…
Yes! Exactly. I'm almost always surprised. And it's really important to remember what benefits you get from the unoptimized code too.
Once I wrote a controller input system in a game engine, the code that monitors and reacts to all the buttons on an xbox controller, for example. I spent a whole bunch of time making sure that when I hit X, the reaction code would trigger with almost no overhead at all. It did fancy stuff like watch for combos and sequences, and game designers could author the control schemes, and I spent a lot of time making sure that actions cost no CPU time.
Then one day I profiled it carefully and found out that the bottleneck was something I'd forgotten to check for -- the case when no buttons were being used. The case that is happening during 99.5% of frames.
The loop to check if something needed to be done had a pretty bad memory access pattern than was missing cache most of the time. I thought it would be close to a no-op, but it wasn't. I had to refactor the whole thing and flip it inside out, and I realized I'd wasted a bunch of dev time fixing the code that reacts to one button at a time. It doesn't matter how slow a single action is, because it'll never show up in the profile. It does matter if I waste a few hundred thousand cycles traipsing through memory missing cache with every instruction.
Re: How much your computer can do in a second
#73Earlier quoted context omitted.
How would you optimize sum.c to be faster?
Well the obvious answer would be, eliminate the loop, which is what any compiler optimizer will do ;) But let's assume that the operation is not quite so trivial like here, then this structure would be a prime example where each loop operation is independent from each other, so you can sum a vector in parallel (=SIMD) and then sum the vector once in the end. Also, since we're obviously not using any compiler optimiza…
Re: How much your computer can do in a second
#74Re: How much your computer can do in a second
#75If, like me, you spend most of your time in high-level, garbage collected "scripting" languages, it's really worth spending a little time writing a few simple C applications from scratch. It is astonishing how fast a computer is without the overhead most modern languages bring in. That overhead adds tons of value, certainly. I still use higher level languages most of the time. But it's useful to have a sense of how f…
>> It is astonishing how fast a computer is without the overhead most modern languages bring in.
The other interesting thing with high level languages (using Python as an example) is that a small number of features that are not often used keep the language from running significantly faster (see PyPy for example).Seems like there should be room for a language with slightly reduced set of Python features (Py--) which runs much faster.
Re: How much your computer can do in a second
#76Earlier quoted context omitted.
Well the obvious answer would be, eliminate the loop, which is what any compiler optimizer will do ;) But let's assume that the operation is not quite so trivial like here, then this structure would be a prime example where each loop operation is independent from each other, so you can sum a vector in parallel (=SIMD) and then sum the vector once in the end. Also, since we're obviously not using any compiler optimiza…
When you say "eliminate the loop", do you mean loop unrolling? They are compiling with -O2, I'm not sure if that does loop unrolling. If it does, how much unrolling does it do, exactly? I can't imagine it would construct a block of code with a billion add instructions.
or
s = NUMBER
Re: How much your computer can do in a second
#77Earlier quoted context omitted.
How would you optimize sum.c to be faster?
for a data parallel problem like that you could vectorize it using the SIMD unit. It never ceases to amaze me at any point how much of silicon real estate just sits idle because no one really bothered to look behind the curtain and tailor the code for a specific architecture. for reference, a recent Intel chip will have 256b wide vector unit (512 for server class chips) that can be treated as a vector of 8/16/32/64b…
Re: How much your computer can do in a second
#78Alternatively, this could be titled "do you know how much your computer could do in a second but isn't because of bad design choices, overengineered bloated systems, and dogmatic adherence to the 'premature optimisation' myth?" Computers are fast, but not if all that speed is wasted. A recent related article: https://news.ycombinator.com/item?id=13940014
> Computers are fast, but not if all that speed is wasted. While computers are fast, the performance improvements have been spread very unevenly. CPUs have improved the most, with memory lagging significantly behind, and persistent storage even more distant. On the other hand, networks have become much faster than before. I like this list of Latency Numbers Every Programmer Should Know: https://gist.github.com/jboner…
Re: How much your computer can do in a second
#79Alternatively, this could be titled "do you know how much your computer could do in a second but isn't because of bad design choices, overengineered bloated systems, and dogmatic adherence to the 'premature optimisation' myth?" Computers are fast, but not if all that speed is wasted. A recent related article: https://news.ycombinator.com/item?id=13940014
It's wasted only if it's not traded for something else. But it is. A lot of system would simply not exist if we would have waited for people doing it properly because there is a limited pool of very skilled experts and the demand for IT far exceed our ability to supply. Plus writing good code takes a lot of time and resources, but our society changes now so fast that it very well maybe rewritten next year. Hence, we…
Except it's none of these things: electron apps suffer the same presentation-before-content problems as most of the web, they inherit all of the state bugs of web apps, and they're painfully slow despite usually just being menus of nested lists and text boxes. It's passing a burden from developers to users, which considering the huge asymmetry between these two groups that's typical (at least 3 orders of magnitude, and often 6 or more) is an enormous inefficiency.
I'm all for selecting tools and platforms to better optimize developer productivity, but it's not clear to me the web platform has actually accomplished that for all but a few types of applications, and pushing it to the desktop is resulting in cumbersome, unresponsive, needlessly fragmented interfaces.
Put simply: Amazon Music Desktop has untold development investment and a complete visual redesign every 6 months, but WinAmp circa 2001 is somehow a thoroughly better way of searching and playing music.