Live data from Hacker News

How much your computer can do in a second

computers-are-fast.github.io

121–130 of 244 posts

Re: How much your computer can do in a second

#121
post #58
post #34

Earlier quoted context omitted.

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…

By definition an optimization being premature means it's not necessary in the present. For these situations its like taking a loan for technical debt. In the future you may need 10x the resources to fix but in many environments that's acceptable due to company growth, or like you mentioned, spending money on compute rather then Dev time. That said, I've been amazed what the top engineers in the field can design and i…

> an optimization being premature means it's not necessary in the present.

Yeah, spot on. What's really important is answering the question of what's necessary, that's really the key. Sometimes you do know that optimization will be necessary in the future even when it's not needed right now. If that's the case, the earlier you attack it, the better. But all of us (me included) tend to spend time on things we believe are necessary that turn out not to be.

> For these situations its like taking a loan for technical debt. In the future you may need 10x the resources to fix but in many environments that's acceptable

Definitely. There is the gamble that if you don't know for sure and you wait it might cost a lot more later. But I would go a lot further than that. The problem is that if you take the other route and optimize early on the wrong thing, it makes optimizing the right thing 100x more expensive in the future, not just 10x. It can be more expensive to optimize the wrong thing than it is to optimize the right thing late. This is because optimizations often require a different way to slice the code, to feed the limiting system with a different batch size, or to invert your high-level looping structure and swap the inner loop and outer loop.

If you've ever done image processing in Python, I always think of numpy vs PIL as a good example of slicing your batches a different way -- if you do it the easy way in PIL, you can write cool stuff in an hour, but your code might take 60 seconds to run on an image. PIL loops over pixels, and you put complex ops inside the loop. Numpy is opposite, you put the operations on the outside, and the loops on the inside (to allow the loops to be run as native compiled code). Numpy's harder to learn, the code is inside-out from PIL, it takes longer to write & debug, but something that takes PIL 60 seconds will take less than 1 second using numpy.

Most of my serious optimization efforts in C++ have ended up feeling very similar to the PIL vs numpy issue, and what happens is that it takes a ton of effort to optimize the right way because I have to invert my whole program's structure. When I've done that only to discover I didn't optimize the right thing, it's a huge mess to un-invert and re-invert the right way.

> I've been amazed what the top engineers in the field can design and implement getting things right the first time without additional effort. Simple, minimalist, high performance implementations that don't sacrifice much.

Same here, some people seem to hit the right balance with less effort. Sometimes it's experience and good guesses, but often (from what I've seen) it's because if you watch the best engineers work, they spend more time communicating up front to make sure they're doing what's really needed, and they spend more time checking their assumptions as they go, writing tests, profiling, and talking with their peers and their management about what they're doing. They're able to recognize quicker when they're spinning their wheels on problems they want to solve, and not problems that the team or product really truly needs solved.

Re: How much your computer can do in a second

#122
post #118

Earlier quoted context omitted.

Actually, some software like facial recognition or OCR, does have sleep calls inserted because people don't believe it can be done as fast as it can be done. Thus, whenever I deposit checks at the ATM, I have to stand there and watch as some entirely unnecessary animation pretends to scan my check for ten seconds before I can have my card back.

Yes, the same applies to save buttons. If saving takes less than 200ms people are not confident the save really happened. There are also UI animations that deliberately slow things down to prevent the user from getting disoriented. This doesn't prove that product managers want software to be slow though.

Agreed. I think PMs have their own motivations, but ruining things for others is not explicitly part of their grand plan.

Re: How much your computer can do in a second

#123
post #102

Earlier quoted context omitted.

Why do you think our tools are inadequate? What would adequate tools be able to do that our current ones can't?

Way too much to cover in depth. In short, it's all terrible. We're mostly using tools from the 70s, and we're still to this day plagued by use-after-free and out-of-bounds errors, nullpointer exceptions, awful debuggers, race conditions, slow compilation times, bad primitives for multithreaded work, just to name a few. We've known for decades that we can do better and ways to do better have been studied in depth by a…

> We're mostly using tools from the 70s

We're using the shittier tools from the 70s, because the better tools died off - which is sad, because we still didn't manage to recreate some of the features those tools offered. The success of UNIX and C seems to be caused by the same phenomenon that causes Electron to succeed and bloat to proliferate - what wins aren't good solutions, but those which get popular quickly.

Re: How much your computer can do in a second

#124

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

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

Re: How much your computer can do in a second

#125
post #55

Earlier quoted context omitted.

> some of the ES6 goodies, like 'let', are actually bad practice... 3x slower than using var This is good to know! I suspected, but never verified. I assume this will get fixed over time, since 'let' is brand new. But JavaScript in general isn't well suited to image filtering, right? Certainly worth using, if at all possible, either CSS filtering or WebGL. Either of those will be much faster. Depending on what you're…

>either CSS filtering or WebGL CSS only has basic filters, and WebGL is only possible for per-pixel manipulation, such as brightness or contrast. This is because WebGL is just shaders, and half of shaders are per-pixel, along with some other fun things you can use with multiple buffers, but you can't actually get /back/ the processed data even if you got all the pixels into a single loop. With WebGL 2, this may be di…

> but you can't actually get /back/ the processed data even if you got all the pixels into a single loop

Oh if you need the pixels back, you can certainly get them using glReadPixels(). It's a bit expensive in WebGL land, though it is much less expensive than looping over pixels using JS. And often there are ways to get around needing the pixels back, depending on what you're doing.

You can also do loads of non per-pixel tricks, including filters that need the surround, using multiple passes and clever shaders, you are not as limited with WebGL 1 as you think.

https://5013.es/toys/dithering/

https://www.shadertoy.com/view/MslGR8

This is what I'm talking about, you have to slice your program differently if you optimize it. Your high level structure and outermost loops will look different if you use WebGL instead of JS. And yes WebGL 2 is even better.

But, this is all much trickier than writing your straightforward loops in JS. That's the price you pay for performance, your architecture will be kinda crazy if you do it in WebGL, and it will not be easy to go back if you discover you optimized for the wrong thing.

Re: How much your computer can do in a second

#126

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

Yep, I've recently written a RFC2822 (and friends) message parsing library in C that can parse 4GB of email messages per second (incl. full bodies decoding and normalizing everything to utf-8) on my old Ivy Bridge i5. Part of the trick is never tying number of malloc() calls to the number of messages/size of input, not using crappy OOP like interfaces, and avoiding string comparisons, which is all possible. My library has no malloc(), no strcmp() and no OOP. :)

It's about 4 times faster than gmime (also written in C - but kind of unfair comparison, because gmime is not doing the body decoding and conversion to UTF-8 by default) and 20 times faster than Python (in a single thread). Now if only I could have a SSD that could read my mail archive that fast. :)

Re: How much your computer can do in a second

#127

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…

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

> To pick just one example, software in the 90s didn't have inline spell checking

To pick on your example - it is interesting that you have to go back 20 years to find a feature beneficial for the everyman, and that you are still wrong: Just about every word processor starting from MS Word 95 came with inline spell checkers. (And indeed I prefer the snappiness and identical feature set of my copy of Office 2003 to the ribbon-laden gigabyte-guzzling mostrosities of Office 201x, just as I prefer a 15-year-old Winamp to the latest Itunes player.)

Re: How much your computer can do in a second

#128

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…

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

> To pick just one example, software in the 90s didn't have inline spell checking as you type

What? Which 90s exactly did you live through? Because I seem to remember MS Word 6.0 having not just spell checking as you type, but also the dreaded autocorrection feature. That was in 1993 according to Wikipedia.

Re: How much your computer can do in a second

#130
post #90

Earlier quoted context omitted.

I mostly do back end code. But when I look at electron and compare it to something like QT Quick, QT Quick looks much more pleasant and easy to use to me.

Electron targets front end dev and people with knowledge of JS + HTML + CSS.

So, your claim is that using electron has got nothing to do with it being easier or simpler. It's just running off inertia?
Post reply on HN