Live data from Hacker News

How might software development have unfolded if CPU speeds were 20x slower?

news.ycombinator.com

51–60 of 161 posts

Re: How might software development have unfolded if CPU speeds were 20x slower?

#51
post #41

Everything would be exactly the same, except 8.64years later. Moore's law show that CPU speeds double every 2years. 2years * log2(20) = 8.64years, so we'd just be 8.64years late, that's it, literally no reason for anything to be any different apart from that. 95% of comments seem to completely overlook this fact and go into deep explanations about how everything would be different. It's pretty surprising that even a…

Still think mine is even more general :)

Obligatory XKCD: https://xkcd.com/435/

My comment: https://news.ycombinator.com/item?id=39977838

Re: How might software development have unfolded if CPU speeds were 20x slower?

#52

I feel like every time CPU speeds double, someone comes up with a Web UI framework that has twice as much indirection. With 20x slower compute, we might not have UIs that fire off an event and maybe trigger an asynchronous network request every time you type a character in a box, for example. Windows 95 could do a decently responsive desktop UI on an 80386. Coding was a lot less elegant in one way - C code that retur…

I do wonder about this often. Are these new UI frameworks iterating upwards towards some unknown featureset archetype, where if given another 10-20 years, the designers will say "Okay, we've reached diminishing feature returns, let's pack it up and optimize" Or, are we simply re-inventing the wheel each time, where the set of features over the last few decades really haven't change that much or cycles through feature…

I would say, to go with the metaphor, that none of our wheels are close to round yet, and every now and again someone invents a new wheel that has a different kind of bump.

Concretely, "shadow DOM", reactive (web) components and js frameworks etc. etc. are all ways of trying to get a set of rich UI components (like we're used to from desktop applications) into an environment that was originally built for static text pages, and has been expanded by patchwork ever since. DOM updates are slow and cause flickering because the original model was you submit a form and the entire page reloads; updating part of the page in response to an asynchronous request or a local event wasn't in the original design space, and every solution we've tacked on so far sucks in a slightly different way. Not helped by the complexity of being able to dynamically change the layout and size of every single element - CSS is incredibly powerful, but setting a button to have a 1px border only on hover for example has a tendency to make other page elements "jiggle" in ways you don't want.

Re: How might software development have unfolded if CPU speeds were 20x slower?

#53

HN answer: To stick with your analogy: There would be more optimization and the rate of releasing stuff would be slower because it would have to be tested. That's it. Remember catrdige based console games? How many patches or day one updated did you have to install there? How many times would they crash or soft-lock themselves? People tested more and optimized more because there were constraints. Today we have plenty…

For the Sci-Fi answer our language would be optimized for extremely fast communication, maybe making sounds from our mouths alone would be way to inefficient. We probably would have easily made stuff that caught up with our cognition. The current hardware and software is more a representation of human limits than other limits.

I think the frame of wasteful is not correct. It's wasteful not to use resources if other resources are restricted and can be substituted by the plentiful. Of course the allocation of current resources can be debated but that is not caused by extra CPU performance, storage and RAM that is available.

Re: How might software development have unfolded if CPU speeds were 20x slower?

#54

I write C++ for high-performance Windows desktop applications that are used on a wide variety of form factors. This means that I still optimize a lot of things, such as what happens when a user edits a property in an edit box. How can that edit be minimized? How do I make sure that commands operate in less than a second? How can we hide latency when a long execution time can't be avoided? 99% of the time, optimizatio…

Sidenote: MSVC had an optimization option for Windows 98, I think it was /OPT:98 (/FILEALIGN:4096). It sets the "file alignment" of sections in the portable executable (PE) file to 4096 bytes (0x1000) = 1 memory page -> noticeably more efficient because it's a direct copy operation. It's sacrificing space (padding empty space with thousands of zeros) for time (one copy operation instead of many to shuffle data into memory pages).

(The file alignment still defaults to a 512-byte (0x200) sector size which means the inefficiency is there today even though you may not notice it in isolation, but the "sector"/buffer size has been at least 4096 bytes since 2011. [2])

> The /FILEALIGN option can be used to make disk utilization more efficient, or to make page loads from disk faster. [Assuming it matches the page size = 4096 bytes.] [1]

> All hard drive manufacturers committed to shipping new hard drive platforms for desktop and notebook products with the Advanced Format sector formatting [4096-byte or greater] by January 2011. [2]

[1] https://learn.microsoft.com/en-us/cpp/build/reference/fileal...

[2] https://en.wikipedia.org/wiki/Advanced_Format

Re: How might software development have unfolded if CPU speeds were 20x slower?

#55

I write C++ for high-performance Windows desktop applications that are used on a wide variety of form factors. This means that I still optimize a lot of things, such as what happens when a user edits a property in an edit box. How can that edit be minimized? How do I make sure that commands operate in less than a second? How can we hide latency when a long execution time can't be avoided? 99% of the time, optimizatio…

> One time I reduced something from a 15 minute execution time to running hundreds of times per second That's too good a story not to have just a little more detail. Are you willing to share more?

Sure. It was a fairly complicated image processing algorithm, but not necessarily something that you would want to go through a lot of trouble to implement on the GPU. At least not until you're desperate. And I should add, the results are pretty boring. It doesn't even generate anything interesting.

I read the paper that described the algorithm and implemented code on the CPU, thinking, quite stupidly, that it would be fast enough. Not fast, but fast enough. Nope. Performance was utterly horrible on my tiny 128x128 pixel test case. The hoped-for use cases, data sets of 4096x4096 or 10000x10000 were hopeless.

Performance was bad for a few key reasons: the original data was floating point, and it went through several complicated transformations before being quantized to RGBA. The transforms meant that the loops were like two lines total, with an ~800 line inner loop, plus quantization of course (which could not be done until you had the final results). In GLSL there are functions to do all the transformations, and most of them are hyper-optimized, or even have dedicated silicon in many cases. FMA, for example.

So I wrote some infra to make it possible to use a compute shader to do it. And I use the term 'infra' quite loosely. I configured our application to link to OpenGL and then added support for compute shaders. After a few days of pure hell, I was able to upload a texture, modify the memory with a compute shader, and then download the result. The whole notion of configuring workgroups and local groups was like having my pants set on fire. Especially for someone who had never worked on a GPU before. But OpenGL, it's just a simple C API, right? What could go wrong? There's all these helpful enumerations so the functions will be easy to call. And pixel formats, I know what those are. Color formats? Oh this won't be hard.

But once everything was working, it only took a few more days to make the compute shader work. The hardest part was reconfiguring my brain to stop thinking about the algorithm in terms of traversing the image in a double nested for loop - which is what you would do on the CPU. Actually, the first time I wrote it, that's what I did, in the shader. Yes, I actually did that. And it wasn't fast all. Oh man, it felt like I was fucked.

But in the end, it could process the 4096x4096 use case at 75 FPS, and even better, when I learned about array textures, I found that it could do even more work in parallel. That's how I got it from 15 minutes to hundreds of frames per second.

Re: How might software development have unfolded if CPU speeds were 20x slower?

#56
post #8

More C/C++ based business apps that run locally. Cloud would be less relevant. No large browser engines, which means a lot less JS and of-course no Electron :)

There would be way more language and tool development around more efficient languages because more people would be required to use them. So C and C++ would probably be in a totally different state. There would be a huge amount of hate for people who use some C++ derivative with a framework on top of it using some program that allowed it to easily run on multiple systems.

Re: How might software development have unfolded if CPU speeds were 20x slower?

#57

Earlier quoted context omitted.

Do you happen to have any pointers or recommendations regarding C++ for desktop applications? Especially towards state-management and user-interaction? I am primarily doing game development and HPC; I am decently familiar with C++, but desktop UI has been a pain point for me so far. Most GUI tools I write in C++ are using ImGui, or they are written in C#.

Desktop UI is painful. It doesn't help that Microsoft is seems to have quite a few competing UI frameworks and technologies these days. 1. What is your goal? Do you need to run on Windows and Linux? QT isn't bad, although I personally think the UI looks a little weird. It is definitely highly opinionated and parts of it are quite strange IMHO. There's probably lots of jobs writing with QT, which might be a nice side…

> I would draw everything myself.

I wouldn't be too fast to recommend this. I have quite a lot of experience with Qt[1], and I manged to get a good look and feel across different operating systems. Yes, you'll need to customize Qt Quick components yourself. But that's easy. Also, Qt is improving its support for native components, they now support native dialogs and file pickers in Qt Quick[2]. Another important thing, is that you can always extend your app using open source libraries - for example - qwindowkit allows you to create native frameless windows.[3]

I highly recommend Qt. And related to this post, you can write some extremely responsive and fast applications with it.

[1] https://www.get-plume.com/

[2] https://doc.qt.io/qt-6/qtlabsplatform-index.html

[3] https://github.com/stdware/qwindowkit

Re: How might software development have unfolded if CPU speeds were 20x slower?

#58
post #54

I write C++ for high-performance Windows desktop applications that are used on a wide variety of form factors. This means that I still optimize a lot of things, such as what happens when a user edits a property in an edit box. How can that edit be minimized? How do I make sure that commands operate in less than a second? How can we hide latency when a long execution time can't be avoided? 99% of the time, optimizatio…

Sidenote: MSVC had an optimization option for Windows 98, I think it was /OPT:98 (/FILEALIGN:4096). It sets the "file alignment" of sections in the portable executable (PE) file to 4096 bytes (0x1000) = 1 memory page -> noticeably more efficient because it's a direct copy operation. It's sacrificing space (padding empty space with thousands of zeros) for time (one copy operation instead of many to shuffle data into m…

People like you remind me that I'm still an amateur at all this :)

Re: How might software development have unfolded if CPU speeds were 20x slower?

#59
post #36

I feel like every time CPU speeds double, someone comes up with a Web UI framework that has twice as much indirection. With 20x slower compute, we might not have UIs that fire off an event and maybe trigger an asynchronous network request every time you type a character in a box, for example. Windows 95 could do a decently responsive desktop UI on an 80386. Coding was a lot less elegant in one way - C code that retur…

I saw a talk about tigerbeetle the other day - which is a small, fast database for handling financial transactions that apparenty runs orders of magnitude faster than Postgres. The database binary has no dependencies and compiles to 500kb. Its authors were joking they could distribute it on floppy disks if they wanted. It’s written in Zig, not C. But that style of programming is still available to us if we want it. E…

Back when Java had just introduced Swing to supplement/complement AWT, I remember you had a set of components (that you could even style in different ways with themes), a fairly object-oriented approach, and with the open-source MiG layout manager (that still exists today) a powerful way of laying out forms with constraints to adapt to changing screen/window/font sizes. I feel like UI framework progress from Windows 3.1 to Swing+MiG was much greater than anything I've seen since.

Re: How might software development have unfolded if CPU speeds were 20x slower?

#60
post #41

Everything would be exactly the same, except 8.64years later. Moore's law show that CPU speeds double every 2years. 2years * log2(20) = 8.64years, so we'd just be 8.64years late, that's it, literally no reason for anything to be any different apart from that. 95% of comments seem to completely overlook this fact and go into deep explanations about how everything would be different. It's pretty surprising that even a…

Moore's Law actually refers to the density of transistors on a chip doubling approximately every two years, not CPU speed. Yes, CPUs still get exponentially faster, but this affects multi core throughput, single thread performance improves way slower. For human perception and interactivity, this makes a huge difference. So it stands to reason if algorithms would have been parallelized earlier and better, but I doubt that the timeline would just be shifted a few years.
Post reply on HN