Live data from Hacker News

How much your computer can do in a second

computers-are-fast.github.io

41–50 of 244 posts

Re: How much your computer can do in a second

#41
post #3
post #2

More impressively, sum.c could go likely an order of magnitude or so faster, when optimized. > Friends who do high performance networking say it's possible to get network roundtrips of 250ns (!!!), Well stuff like Infiniband is less network, and more similar to a bus (e.g. RDMA, atomic ops like fetch-and-add or CAS). > write_to_memory.py Is also interesting because this is dominated by inefficiencies in the API and i…

How would you optimize sum.c to be faster?

You can't really do loop unrolling and constant folding as some suggest because the number of iterations is determined at run time.

But assuming his CPU takes one cycle for an addition and one cycle for a conditional jump, his CPU only needs to run at 1GHz to achieve his result.

Given that branch prediction should be nearly perfect for such a simple and short loop, modern x86 CPUs doing at least 4 integer additions per cycle, and typical CPU speeds in the range of 2-4 GHz, a properly optimized version should be nearly an order of magnitude faster.

So either more aggressive compiler flags and maybe SIMD intrinsics, or hand written assembly (easy here, not so easy in the real world)

Re: How much your computer can do in a second

#43
post #22

Yes, modern computers are fast. How fast? The speed of light is about 300,000 km/s. That translates to roughly 1 ns per foot (yeah, I mix up my units... I'm Canadian...) THUS, a computer with a clock speed of 2 GHz will be able to execute, on a single core/thread, about 4 (four !) single-clock instructions between the moment photons leave your screen, and the moment they arrive into your eye 2 feet (roughly) later. _…

Holy crap, you're right. 2 instructions per light-foot! That is a very cool comparison!

Makes me think maybe light is slower than I thought. And that Word must have a lot of code running. :P

Re: How much your computer can do in a second

#44
If, 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 fast you could make some computation go if you really needed to.

Re: How much your computer can do in a second

#45
post #34

Alternatively, 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

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…

>I find premature optimization to be far, far more wasteful of money and human energy than wasted CPU cycles.

I would argue this always depends upon what you're doing. For example, in webdev, the culture of prototype fast and break things fast is very abundant, and makes sense when you're just trying to figure out if what you want done is even possible. However, there are many times where you /do/ have to consider the performance impact, because with it, what you're making isn't going to be nice to use.

By dogmatic, I think they meant individuals who will actually argue that '100ms' loop times are 'tiny' and shouldn't be a problem. They don't get the concept that its just one small part of your code, and the rest of it combined can make an entire process take up to 5-10 seconds to do something that should be in a blink or two. Learning about optimization is a part of learning programming, and knowing when to use it. The problem is when you don't know it, and fumble around trying to do so when you've got much bigger problems further ahead.

I ran into this problem a lot with image filtering and working with Canvas's to build an image editor. I talked with some communities about the Uint32Array implimentation in chrome and other browsers and how some of the ES6 goodies, like 'let', are actually bad practice when you start to get into image filtering, because just iterating over all the pixels in an image by using "for(let i=0;iTypeScript compiles down to var, though, so its less of a problem there, but I met a lot of resistance in that statement in general, even though its true, because there's a lot of dogmatism in programming. At the end of the day I'd rather learn and teach good practices and not tell people they're pre-optimizing unless they really don't know much about what they're working with.

Re: How much your computer can do in a second

#46

Alternatively, 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

The market is wasteful. Lots of things are subpar because of the competition requiring adhoc solutions pushed to market, then becoming standard, so on and so forth. You can blame the game or not. At least if there was some acknowledgement of that process and a little cleanup time to spread good ideas and good fix ... Personally I always feel weird booting up old boxes (say old = Pentium 2) and realizing how much the…

On further consideration, though it's common to talk about an upgrade treadmill or "what Andy giveth, Bill taketh away", software actually does get better over time, and we shouldn't look back so fondly on older versions. To pick just one example, software in the 90s didn't have inline spell checking as you type, a feature that came in handy for me just a few minutes ago while editing my other comment. Still, the question remains: why doesn't everything feel instant on our current systems, and what do we do about it?

Re: How much your computer can do in a second

#47
post #20

Earlier quoted context omitted.

The market is wasteful. Lots of things are subpar because of the competition requiring adhoc solutions pushed to market, then becoming standard, so on and so forth. You can blame the game or not. At least if there was some acknowledgement of that process and a little cleanup time to spread good ideas and good fix ... Personally I always feel weird booting up old boxes (say old = Pentium 2) and realizing how much the…

An eye-opening experience is running an IDE like Visual Studio 6 or a really old version of Photoshop on a modern machine. It starts instantly, compile times are a fraction of what we're used to. The interface is totally responsive. It's remarkable how much better software feels when everything is instant.

Similarly, I run a very barebones Openbox Arch Linux install on my ancient 2Ghz Turion 64 laptop and I recently booted Windows XP on it and I was blown away by how fluid & responsive the entire system was compared to my much newer Linux-based OS.

Re: How much your computer can do in a second

#48

Earlier quoted context omitted.

Or start with the current version, then demo the ancient version, and claim you've "streamlined and tuned" the program?

What I was getting at is that the suggestions to add crap would come from the product manager candidate themselves - thereby "proving" (if the results match my prediction) that the requirement for slow unresponsive interfaces come directly from the PM's, who would add it if it weren't already slow. Like, I want the experiment to test if a product isn't already slow, would a product manager actively make it slow? (I t…

When software is too slow it hurts sales. When software lacks features that hurts sales too. Faster doesn't make for compelling marketing (anybody can claim their software is fast) but you can get people to upgrade for new features. So features are added with every release and performance improvements are made up so to the point where it's "good enough" again. You don't need a product manager conspiracy to explain why software is bloated and slow.

Re: How much your computer can do in a second

#49
post #41
post #3

Earlier quoted context omitted.

How would you optimize sum.c to be faster?

You can't really do loop unrolling and constant folding as some suggest because the number of iterations is determined at run time. But assuming his CPU takes one cycle for an addition and one cycle for a conditional jump, his CPU only needs to run at 1GHz to achieve his result. Given that branch prediction should be nearly perfect for such a simple and short loop, modern x86 CPUs doing at least 4 integer additions p…

> You can't really do loop unrolling and constant folding as some suggest because the number of iterations is determined at run time.

Huh?

Re: How much your computer can do in a second

#50
post #47
post #20

Earlier quoted context omitted.

An eye-opening experience is running an IDE like Visual Studio 6 or a really old version of Photoshop on a modern machine. It starts instantly, compile times are a fraction of what we're used to. The interface is totally responsive. It's remarkable how much better software feels when everything is instant.

Similarly, I run a very barebones Openbox Arch Linux install on my ancient 2Ghz Turion 64 laptop and I recently booted Windows XP on it and I was blown away by how fluid & responsive the entire system was compared to my much newer Linux-based OS.

Also, surprisingly, XP could handle 64MB decently (even for a nazi like me)
Post reply on HN