Live data from Hacker News

Computers are fast

blog.hackensplat.com

41–50 of 54 posts

Re: Computers are fast

#41
No need to brute-force. It's pretty easy to just eliminate possibilities:

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.

Re: Computers are fast

#42
Definitely makes you think about opportunity cost in terms of CS: spend time writing an efficient algorithm or just bust out the ole brute force. Surprisingly, brute force works really well with the excess performance we all have sitting around...

...until you have several hundred users hitting your server running that brute force algorithm. Sigh.

Re: Computers are fast

#43
One thing I beat on my development staff about is that computers are fast, stupid fast. As in billions of operations per second fast. With rare exception, if I do an operation on something in memory, it shouldn't take any more than 1/2 a second for it to happen. This extends to UI interactions, selecting a few thousand items in a list shouldn't take 4 seconds a disk swap.

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.

Re: Computers are fast

#44
post #25

Earlier quoted context omitted.

I don't think so. 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.

There's 2 to 3 feet between me and my screen, my cpu has 2 cores, and modern CPUs can perform many simple arithmetic operations per clock cycle, per core. Not to mention what's happening in my GPU.

Let's take a concrete example. A Core-i7 980X Extreme Edition, the latest and greatest from Intel, can execute a maximum of four instructions in a clock cycle. (The numbers on actual code are probably a little over 1 instruction per cycle, which is really pretty good.) It runs at 3.33 GHz and has 6 cores. That's a theoretical maximum of about 43.336 = 79 instructions per nanosecond, on all cores combined. Assuming I didn't make some dumb arithmetic mistake.

Of course, in real code you'll be lucky to get anywhere near that.

Re: Computers are fast

#45
post #42

Definitely makes you think about opportunity cost in terms of CS: spend time writing an efficient algorithm or just bust out the ole brute force. Surprisingly, brute force works really well with the excess performance we all have sitting around... ...until you have several hundred users hitting your server running that brute force algorithm. Sigh.

Most developers like to imagine they're going to have somewhere between 100 and 10,000 concurrent requests on their webserver shortly after launch, so they have to write really efficient algorithms. The reality is usually considerably less demanding. In most cases, its usually just cheaper to throw hardware at it. Of course, in some rare cases, algorithm efficiency is crucially important, but this is pretty rare.

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.

Re: Computers are fast

#46
post #4

Yes. Computers are fast. Who cares about algorithms... Premature optimization is evil... But why then it is so annoying that Visual Studio starts longer than my whole custom linux system in VM on the same computer...

That's very weird. I can launch VS 2010 in < 3 seconds cold on my system. Maybe its a VM thing? VS might always think its launching for the very first time ever on that machine, so it has a lot of heavy duty, one time only things, but on a VM, it does this every time you boot the VM?

Re: Computers are fast

#48
post #44
post #25

Earlier quoted context omitted.

There's 2 to 3 feet between me and my screen, my cpu has 2 cores, and modern CPUs can perform many simple arithmetic operations per clock cycle, per core. Not to mention what's happening in my GPU.

Let's take a concrete example. A Core-i7 980X Extreme Edition, the latest and greatest from Intel, can execute a maximum of four instructions in a clock cycle. (The numbers on actual code are probably a little over 1 instruction per cycle, which is really pretty good.) It runs at 3.33 GHz and has 6 cores. That's a theoretical maximum of about 4 3.33 6 = 79 instructions per nanosecond, on all cores combined. Assuming…

Regarding double precision calculations (I can't compare random instructions) at the time OP mentions the PC FPU made something of the order of KFLOPS. Even assuming 100 KFLOPS (it was less), one current graphical card can be up to 5 million times faster than the PC of that time in some scientific calculations, that is, the gamer of today has under his desk the computing power of 5 million first PC computers.

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.

Re: Computers are fast

#50
post #11

Something I like thinking about: Your computer can (probably) perform a few dozen arithmetic operations or a few stores/reads in the time light leaving your monitor takes to reach your eye balls. edit: not to mention GPUs

I wasted most of the early 90s doing that. 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 i…

Around '94 I used a close to the top of the range (at least in CPU power) DEC Alpha workstation - which I used for running Lisp programs.

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!

Post reply on HN