News for hackers. Stuff that matters.
Re:Computers are fast by cessor on Tuesday May 13, 2014 @04:30AM (#7737068)
I like the "free" style of the article. Here is another conclusion: In my professional life I have heard many, many excuses in the name of performance. "We don't need the third normal form, after all, normalized databases are less performant, because of the joins". Optimizing for performance should not mean to make it just as fast as it could possibly run, but to make it just fast enough.

Julia's article shows a good example for this. Of course, the goal appears to generate a feeling of what tends to make a program fast and slow and get a feeling for how slow it will be or how fast it can get; yet I'd like to point out that this...

https://github.com/jvns/howcomputer/blob/master/bytesum_intr...

... might be 0.1 Seconds faster than the original code when started as "already loaded into ram" which she claims runs at 0.6 seconds. Yet this last piece of code is way more complicated and hard to read. Code like this

Line 11: __m128i vk0 = _mm_set1_epi8(0);

might be idiomatic, fast and give you a great sense of mastery, but you can't even pronounce it and it it's purpose does not become clear in any way.

Writing the code this way may make it faster, but that makes it 1000x harder to maintain. I'd rather sacrifice 0.1 seconds running time and improve the development time by 3 days instead.

Re:Computers are fast by heffo on Tuesday May 13, 2014 @05:05AM (#7737168)
I believe that the author meant to write 0.25 seconds, instead of 0.5 seconds. She says that the one step halves the running time, and later on she is investigating how the 0.25 seconds are split up.

A >50% speedup is not to be sniffed at! I completely agree with your point though, unless it is mission critical that this code runs as fast as possible, then you are better off keeping it simple!

Re:Computers are fast by bithush on Tuesday May 13, 2014 @04:44AM (#7737103)
Depends if that 0.1 seconds is going to add up to a very significant amount. Obviously these are just tests but in a production system running 24/7 that 0.1 seconds per run is going to add up to a lot. The code might be ugly but that is when comments are most important.
Re:Computers are fast by pjc50 on Tuesday May 13, 2014 @05:27AM (#7737239)
Or it might add up to next to nothing, if a full run is eight hours. Or it might finish early and then be blocked waiting for some other part of the system.

The moral of "computers are fast" is that guessing about bottlenecks and twiddling with the lowest level of code is unlikely to help; you need to start at the top with a profiler, and start asking the questions "do we need to compute this at all?", "can we make it O(n log n) or better?", and "can we partition this to scale horizontally?"

Re:Computers are fast by jononor on Tuesday May 13, 2014 @11:26AM (#7738579)
Not only at the top, but with profiling a task that is relevant for the user. It is trivial to find some code that could be "speed up", but if it does not bring any value to the user, what is the point?
Re:Computers are fast by blt on Tuesday May 13, 2014 @01:45PM (#7739525)
That's why you write a C++ class wrapping the SSE intrinsics :)