Live data from Hacker News

How much your computer can do in a second

computers-are-fast.github.io

221–230 of 244 posts

Re: How much your computer can do in a second

#221

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

That's Wirth's Law: https://en.wikipedia.org/wiki/Wirth%27s_law

How bad is the problem? https://hubpages.com/technology/_86_Mac_Plus_Vs_07_AMD_DualC...

Re: How much your computer can do in a second

#223
post #60

Earlier quoted context omitted.

>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 th…

> ES6 goodies, like 'let', are actually bad practice... BTW, this is a really good example of why people like to avoid premature optimization. Performance oriented code frequently has to break all the rules, it often goes against all "best practices" for code that isn't performance critical. If you do it too early, you will wreck your codebase's ability to deal with 1- non performance critical code and 2- other perfo…

>using map() has historically been about 10x slower than using a for loop.

Wow, really? Any idea why? Seems odd when map() imposes fewer guarantees and can be implemented, in the worst case, with a for() loop...

Re: How much your computer can do in a second

#224
post #219

Earlier quoted context omitted.

Worth checking out Common Lisp. It's as high-level language as you can get, and yet good compilers (like SBCL, or like commercial ones from Franz and LispWorks) can compile it to tight assembly with performance very close to that of C++ (you need to disable some runtime checks for that though, but you can do that on a per-function level, so it's much less of a problem than one thinks).

But you still don't get any control over memory layout of your data and how allocations are performed and this could easily cost you an order of magnitude in performance.

True, at least without using any vendor-specific extensions (that may or may not help here; I haven't investigated). My point was that in CL, you get close-to-C++ performance levels by default, you can get even closer by optimizing specific areas in your code, and all of that while still writing in a very high-level language. Of course you won't beat memory-optimized C++ code in performance, but you're already close enough that you rarely need to.

Re: How much your computer can do in a second

#226

Earlier quoted context omitted.

> 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)

That was so acid. ;-)

But besides my pun, "fast" code is a moving target relatively to the end result (see how performance considerations about Java running in a VM became moot because of hardware improvements notably on the CPU; see how today multithreading is making a comeback to rescue CPU-bound applications from stale improvements).

Fast is also subjective, it's cultural in that it's a trained perception. I'm annoyed if Excel takes more than a couple seconds to launch, but most people are used to 10s at least, because that's our daily experience. Likewise, I remember a time when having pixelated thumbnails until images loaded completely over dozens of seconds was the best browsing experience; nowadays on fiber/LTE we expect a page to appear rather instantly.

I guess what subconsciously annoys the hell out of "those who like as fast as possible applications" with Electron is that we know it will yet make fast a more distant concern overall, at least until hardware makes the Electron performance penalty moot, like Java VM.

I'm pretty convinced 'fast' is indeed a clear third priority for most consumers though, seeing how it doesn't seem to bother most people in UX research (less so than many other concerns), or how Apple rides ever more financial success while releasing ever slower hardware and software (comparatively to the whole market, and sometimes astonishingly even to their own previous models). Facebook is bloated as hell too these days, but it's as popular as ever. Spotify is sluggish too, even Twitter. People just don't seem to care, the looks and simplicity of use seem more determinant.

Re: How much your computer can do in a second

#227

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

You're nearly right: but premature optimization is no myth, but a massive source of both bugs and wasted effort.

The backlash (e.g. your statement?) against it's misapplication seems to be causing as many problems today as the misapplication, at least in my experience.

It is true that "premature optimization" is used as an (invalid) excuse for lack of or poor design, but if wasn't there another excuse would be found. That's not what Knuth was talking about.

Re: How much your computer can do in a second

#228

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

[deleted]

Re: How much your computer can do in a second

#230
post #213

Earlier quoted context omitted.

>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 bu…

> frag_color returns one pixel Whoa, hang on. Hey I only mean this to be helpful not insulting, but it sounds to me like you may have some misconceptions about the way WebGL works. I know how easily that can be taken the wrong way, especially in text, so again I apologize in advance and I don't mean that to be rude at all. It would be best to back up and understand WebGL. If you're doing image processing in WebGL, th…

>If you're doing image processing in WebGL, then to write many pixels to a framebuffer all at once, you draw a single polygon that covers the entire viewport. Your shader is applied in parallel to all pixels drawn. That is how ShaderToy works, it renders a single quad to the viewport and applies whatever shader you give it, the GPU runs that shader on all pixels rendered.

>Whoa, hang on. Hey I only mean this to be helpful not insulting, but it sounds to me like you may have some misconceptions about the way WebGL works.

You draw a simple quad, which the shader then processes all the pixels in parallel, returning their frag_color as the output color. It can read textures and other source information, but it does not have access to what is being processed currently for other pixels, because its parallel. You have to wait until it has rendered that, and then pass it in again. I am unsure what I am misunderstanding.

>https://webglfundamentals.org/webgl/lessons/webgl-image-proc...

This was a cool insight into using framebuffers for multiple passes, thank you.

>Here is the demo from that article that uses the techniques I've been talking about. All of the filters in this demo are doing neighborhood computations. And note you can apply multiple filters. There is no texture copy here, this tutorial renders directly to a texture in one pass, and then samples that texture in the next pass and so on. The iterations or feedback that you're looking for happen by combining render-to-texture with drawing the viewport polygon multiple times.

From what I'm seeing, this is not just a couple passes, its a pass per-filter. None of the filters singularly rely upon multiple passes, their output is calculated purely on the image that was filtered before it, meaning the filter itself doesn't need to write pixels and then read them again. You can see that in the for loop that calls setFramebuffer() and drawKernel(). I understand that you can apply a shader, and put its output back in, but I still fail to see how you're avoiding doing that at the very least in the hundreds of thousands of times. error diffusion dithering classically is sequential from top to bottom, or bottom to top depending upon serpentine or not, I don't think you can just process a ton of pixels at the same time and still look anything like a sequentially done Floyd-Steinberg.

Post reply on HN