Live data from Hacker News

How much your computer can do in a second

computers-are-fast.github.io

191–200 of 244 posts

Re: How much your computer can do in a second

#191
post #148

Earlier quoted context omitted.

Why do we care so much about the dev? There are way more people who use a typical program than there are people who develop it, and these people often use the program more frequently than the developers make changes to it. For example, if a feature is used every day for a year by 10,000 people, speeding it up by 200ms is worth over a month of developer time (200ms for 10,000 people over a year is 203 hours of time wa…

Who is funding the developer? Why should they spend $5k (plus the opportunity cost of not using that dev's time on more fruitful pursuits) on 2 weeks of micro-optimization so that their 10,000 users will each experience a speedup so small they'll never even notice (and certainly never pay extra for)? How do you justify that expense?

200ms delay is easily noticeable. Even 50ms is noticeable. And latency is cumulative, and your user's hardware already adds some, so you never know exactly how much latency budget you have before the whole system feels unpleasant.

I think 25ms is a reasonable goal, and even 10ms wouldn't be a waste of effort. All interactive software should be written like a fast-paced action game.

Re: How much your computer can do in a second

#192
post #148

Earlier quoted context omitted.

Let's be clear, I dislike slow apps, I think current behemoth web pages size is a monstrosity and every time I start an electron app (minus the excellent vscode), I scream in my head. Yet. Most electron app I tried have a ratio result/effort far better than any other solutions for the dev.

Why do we care so much about the dev? There are way more people who use a typical program than there are people who develop it, and these people often use the program more frequently than the developers make changes to it. For example, if a feature is used every day for a year by 10,000 people, speeding it up by 200ms is worth over a month of developer time (200ms for 10,000 people over a year is 203 hours of time wa…

Only if those 10000 people do something else in that 200ms and also if they multitask it does not matter. Except in some HFT or other specific use cases, i dont think even 100000 will matter 200ms fix.

Re: How much your computer can do in a second

#193
post #177

Earlier quoted context omitted.

Let's be clear, I dislike slow apps, I think current behemoth web pages size is a monstrosity and every time I start an electron app (minus the excellent vscode), I scream in my head. Yet. Most electron app I tried have a ratio result/effort far better than any other solutions for the dev.

> Most electron app I tried have a ratio result/effort far better than any other solutions for the dev. This is more about the experience of the developer. Anyone familiar with GTK or Qt (possibly others) should be able to bang out a UI pretty quickly, in many cases it will be much simpler than HTML+js+CSS. With Visual Studio you could slap together a win32 app pretty quickly. But for some reason we decided we had to…

Cross-platform was mentioned upstream.

Microsoft finally seems to be learning now but I think it will still be a few years before people start creating cross-platform desktop sw in visual studio, if ever.

Re: How much your computer can do in a second

#194
post #117

Be careful what conclusions you attempt to draw from examples when you arent sure what exactly is happening. These examples are actually very wrong and misleading. Take for example, the first code snippet about how many loops you can run in 1 second. The OP fails to realize that since the loop isnt producing anything which gets actually used, the compiler is free to optimize it out. You can see that thats exactly wha…

We automatically generated all the results in this quiz from the programs on the site. None of the loops were optimized out, we ran basically a binary search to figure out the maximum number of iterations you could run in a second. Results and compiler optimizations will of course vary across computers, but they were correct on my laptop on the day that we ran them (in Sept. 2015). If you want to reproduce this on yo…

The -O2 flag wasn't added to the benchmark script until Sept 20th in commit 4a31931, I suspect you ran at least sum.c without that flag since any modern gcc compiler should have optimized away that entire loop.

I downloaded and ran the benchmarks and indeed the search for the 1 second runtime for sum.c never completed -- it never found an answer because the sum binary runs in constant time regardless of the iteration count. In fact, atoi() in sum.c quickly overflowed once the iteration count exceeded 2^31 (since atoi() returns a signed int). I removed the -O2 flag and then I got the same 550429840 iter count as you on my laptop.

The benchmark script isn't really doing a binary search, it's doing a linear search since it's increasing the iteration count by 10% with each loop.

Re: How much your computer can do in a second

#195
One second on what?

A Core i7? A raspberry Pi? A weird octo-core dual-speed ODROID? An old i915-based Celeron? My cell phone? An arduino?

"Your computer" has meant all the above to me, just in the last few weeks. The author's disinclination to describe the kind of hardware this code is running on -- other than "a new laptop" -- strikes me as kind of odd.

Re: How much your computer can do in a second

#196
post #167

Earlier quoted context omitted.

Yes, ordered dither is easier in a shader than error diffusion, that's true, but error diffusion is definitely possible on a GPU. If you need it. Do you really need it? Why not still use the GPU to accelerate whatever parts you can? Even if you dither on the CPU, doing your color filters on the GPU instead of in JS could make the difference between interactive and not. I don't know what you're doing exactly, but when…

>Even if you dither on the CPU, doing your color filters on the GPU instead of in JS could make the difference between interactive and not. Dithering requires quantization. If you mean things like brightness and contrast, yes, webgl is better for that. But quantization with error diffusion dithering is still based upon previous modified pixels, so you cannot just send a bunch of pixel info to webgl, you have to do ea…

> so you cannot just send a bunch of pixel info to webgl, you have to do each pixel seperately.

Why do you think that? You certainly can get previously modified pixels, you can send millions of pixels to WebGL with a single call (as a texture). Nobody calls glReadPixels millions of times, that's a bad idea. :) You might want to investigate multipass rendering techniques. Small kernel convolutions, for example, are standard and simple operations in WebGL. People use blur & edge filters all the time, and those depend on neighborhood computation.

Regarding the 1-d error diffusion shader on shadertoy, it is using a gather instead of a scatter. It's a pull instead of a push, he flipped the operation inside-out. It is still computing error diffusion correctly (but for only a single pixel row). And it's running at 60fps.

This is the whole point I tried to make above multiple times wrt performance: this code looks unrecognizable compared to the straightforward CPU serial way to implement error diffusion.

The reason this example is correct (in 1D) is because it recomputes the error propagation for every destination pixel; it's wasting almost all of the computation it's doing because in this case it's not sharing the error computation. But that doesn't mean it can't -- this is just a proof of concept on ShaderToy, not the limit of what you can do. You can't do multipass with ShaderToy, and multipass is how you share pixel results from one iteration to the next.

> Unless I am missing some magic buffer you can use to write out many pixels to

It sounds like you're missing render to texture and multipass techniques, the ways to use textures as compute I/O. To do multipass in WebGL and share the results of computation from one pass to the next, you create an offscreen framebuffer for your results, and you render directly to that framebuffer. You can then use the result as an input texture for the next pass (via glCopyTexImage2D) or you can read back the buffer (via glReadPixels) and then you repeat. Using glCopyTexImage2D is much faster because you never leave the GPU.

I think you could do error diffusion by rendering the error to a texture, and using a multipass technique that only needs as many iterations as the maximum distance any error could travel. In the worst case it'd probably be the greater of your image width or image height, e.g. 512 passes for a 512x512 image, but in practice I think you'd be done much sooner. That's assuming there isn't something hierarchical and more clever that could do it in log(width) passes, which I suspect there is.

Re: How much your computer can do in a second

#197

Earlier quoted context omitted.

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…

> E.G: wondering why you see electron apps everywhere now ? Because until now making a beautiful, powerful and modern app with a portable GUI was something only a few people would be able to do. Take portable out and it gets so much easier.

take out beautiful and it gets so much easier too.

I guess that gives us:

* portable

* beautiful

* fast

(choose 2)

Re: How much your computer can do in a second

#200
post #177

Earlier quoted context omitted.

> Most electron app I tried have a ratio result/effort far better than any other solutions for the dev. This is more about the experience of the developer. Anyone familiar with GTK or Qt (possibly others) should be able to bang out a UI pretty quickly, in many cases it will be much simpler than HTML+js+CSS. With Visual Studio you could slap together a win32 app pretty quickly. But for some reason we decided we had to…

Cross-platform was mentioned upstream. Microsoft finally seems to be learning now but I think it will still be a few years before people start creating cross-platform desktop sw in visual studio, if ever.

I think their intention is to make VS cross platform but not to provide a cross platform UI stack themselves. Even if they made any of their UI stacks cross platform, it wouldn't be particular compelling compared to something like qt (or GTK if you don't care about cross platform).
Post reply on HN