Computers are fast
blog.hackensplat.com
blog.hackensplat.com
OTOH, I encounter the "computers are fast" phenomenon 9 out of ten times.
Speed is a direct product of simplicity, and for me simple is elegant. I also think speed is important enough for me to feel strongly about cutting down a "feature" or two, to just make the damned thing not take all night to solve your sudoku..
When I put on my kernel dev hat or when I was working on SQL Server I spent all day making sure other me could throw data around haphazardly and not get stuck on a course-grained kernel lock or only hit 1/8 of the pipelines.
Sometimes it's just too much to handle all at once, even if you know what you're doing in both domains.
In nanoseconds, approximately:
10^7 Disk seek
10^4 2KB over 1Gbps
10^2 RAM uncached reference
10^1 L2/L3 cache reference
10^0 L1 cache reference
That's why systems don't feel fast lately. In particular for big data or bloated software that can't fit well within the caches or shared systems doing a lot of frequent switches (VMs in particular.)Many classic assumptions for algorithms are outdated. Like avoiding full sequential scans. Those are fast for simple operations.
http://www.anandtech.com/show/3734/seagates-momentus-xt-revi...
I didn't think SSDs were that important until I read this and was like, "Oh, I should get one." Which I haven't done yet -- soon, though. When AppleCare on my iMac expires.
And the punchline: there's an article on Wikipedia with all of the values pre-computed!
edit: not to mention GPUs
We need 64 transputers to run this in real time, 1 year of PCB layout later = hey we can do this in 16 transputers and a Sparc.
Cue another year of redesign - now it would only take 4 transputers and a Sparc5.
Then a sales guy turns up promising to put the 16 transputers into an FPGA card.
Just before that works we get an i860 board for the Sparc.
Then finally we can do it in software on a Pentium...
One of the other research teams in the department were working on some kind of custom chip for some specialized application and they wanted to show how much better it was than even the best commodity CPU so they gave me a chunk of completely unoptimized vanilla C to compile and run as a benchmark.
Turns out the Alpha was way faster than their chip - which I don't think they were too happy about!
Light travels about 1 foot/nanosecond, so the travel time from monitor to eyeball is 1 or 2 nanoseconds, which might be 2 or 3 clock cycles. So I think at most 3 operations per CPU.
Of course, in real code you'll be lucky to get anywhere near that.
i7 can do 2 double precision adds per clock per core, that would give 36 GFLOPS on 6 cores (assuming 3 GHz clock), and at the same time ATI Radeon 5870 GPU can do 500 GFLOPS in double precision, that's 500 floating point calculations in one nanosecond.
To cross the 0.5 meter distance the light takes around 1.6 ns, which means that during that time the CPU is able to do almost 60 FPU additions and the GPU around 800 FPU additions. Impressive.
But why then it is so annoying that Visual Studio starts longer than my whole custom linux system in VM on the same computer...
But I sure as heck grumble when my computer is slow. "You've got, like, 800 hojillion cycles a second!" I say to it. "How hard is opening a program?!"
Is that hypocritical?
Disclaimer: I am using custom gnu/linux built entirely form sources.
Varnish dev says second-guessing VM is so 1975: http://news.ycombinator.com/item?id=1554656 OR http://news.ycombinator.com/item?id=1760811
Redis dev says second-guessing VM is elite (and not doing so is so 2006): http://news.ycombinator.com/item?id=1760540
... and the plus side is, if an application needs the RAM, no harm done, just dump the file from RAM and read it from disk.
* _The Design and Implementation of the 4.4BSD Operating System_, McKusick et al., p. 29-30.
What SuperFetch does is collect statistics about files hit by processes when they start up, so it can proactively cache bits of those files, to the point that it can cache files read by processes before those processes are ever started, assuming they are either commonly started or started on a schedule.
So, prune! as it swapped digits left to right in a Grey-code-like sequence, test the digits to the left for diagonals (|row#A - row#B| == |A-B|) and don't bother to recurse if its already failing.
Every few minutes - out popped a solution, and it finished in under 25 minutes.
Nowadays, that would take imperceptible time to execute.
1998: "if" too slow; use "case".
2002: "case" too slow; use Boolean algebra.
2006: Boolean algebra too slow, use arrays & pointers.
2010: Who wrote this shit and what does it do? Rewritten to use "if".
I'm kidding, obviously, but this is a very common phenomenon. Developers optimize their algorithms based on real-world performance instead of theory.
I wonder what impact this has on the world, would the cost of computing be dramatically lower (making computers more accessible) if we didn't do this?
There are times though, when they have to go back and revisit something where they just "let the computer handle it" and whatever libraries they happened to be using do the work, and go back and rewrite a bunch of stuff to be performant from scratch. When that happens, there usually is some pretty large speedup, on the order of hundreds of percent.
The largest number must be larger than 7, else the largest possible sum of the three numbers is 21.
If the largest number is 8, then the other two must sum to 15, which is not possible since they must both be 7 or less.
So the largest number is 9, and the other two numbers sum to 14. The possibilities for those other two, with the smallest first are (5 and 9), (6 and 8), or (7 and 7). Clearly (5 and 9) would duplicate the original 9 (5+9+9), and (7 and 7) would duplicate the 7.
So the only possible solution is 6+8+9.
And with a bit of optimization, it would be even quicker.
...until you have several hundred users hitting your server running that brute force algorithm. Sigh.
As much as everyone would like to think they are working on something in the same class as google, facebook, etc, very few projects are comparable. You're better off shipping early, and dealing with scalability when it becomes a problem.
- Billy Zelsnack