Computers are fast (2014)
jvns.ca
jvns.ca
Computers are fast, but software is slow. Software gets slower faster than computers get faster. “What Andy giveth Bill taketh away” is still as true as ever. I’d love to see the industry move to focusing on responsiveness and e.g. timing on productivity tasks for power users (automate the tests) instead of thinner bezels and flatter UIs.
The lack of people developing desktop UIs using native toolkits (or libraries with native wrappers) is disturbingly low. It seems everyone is using these cross-platform behemoths that are just slow as hell.
Imagine how bad things are when people only know the XCode Form builder, get impressed by react/bootstrap builders or think Visual Studio is great on this...
Personal taste aside, UIs tend to be slow for different reasons:
I think the major reason is the mindset of "oh, it's just UI", thinking that UI is not really 'that' important [part of a bigger system] or that anyone can do it. Not enough attention and expertise then goes to UI.
On the other hand, if UI gets enough attention, the effort tends to go to design mostly. You end up with a design department producing beautiful artwork and one poor overworked programmer putting it together. Management tend to overlook the fact, that UI is not just Photoshop or Aftereffects work, but someone needs to actually write the code that uses those pretty graphics assets. This programming part is often misjudged as a trivial step.
Don't even get me started on motion design. This whole discipline can be summed up as "how can we use up more CPU/GPU cycles and make things less responsive".
Then the market became saturated with UI frameworks built on top of web browsers which by itself is a thick, slow and bloated layer - a far cry from native UI performance. Unfortunately this is becoming the norm due to obvious commercial advantages - it's cross platform and it's easier to hire JS UI programmers. I mean good luck finding a programmer with experience in several native UI kits (say Cocoa, MFC and Android) at once. Even finding someone with adequate experience in one of them is hard enough nowadays.
Doing UI properly is expensive.
There's really no incentive to spend 10x the money for high quality native apps anymore, and that's a shame.
I think that's wrong? The first movdqa (15%) moves from RAM to a register, but the second movdqa (17%) moves from one register to another?
17% seems a lot for something that simply moves from a register to another register! It's even slower than the first movdqa, moving from RAM to register, but registers are supposed to be something like 2 orders of magnitude faster to access than RAM (don't remember exactly).
Maybe it's because there are data dependencies? The 3 instructions before the 2nd movdqa use the register xmm0, so the movdqa has to wait for these to finish before it can execute (aka bubble or pipeline stall)
Something like accumulating to three separate SSE registers per iteration and then combining them outside the loop.
But I'd wager it's probably limited by the SSD speed and filesystem caching code at this point.
(Would be easy enough for an assembly guru to prove either of us right or wrong!)
The same code on memory instead of a file gives me around 14GB/s. Maximum I can achieve with threads and/or intrinsics is 18GB/s (theoretical maximum for my dual channel memory is 20GB/s). This is pretty much a memory bounded problem.
I assume the author was using an older gcc version (as mentioned, autovectorization is not really a solved problem), and a lot of time in this scenario is going into file I/O:
real 0m0.126s user 0m0.071s sys 0m0.056s
Attitudes are contagious and I badly want to catch hers!
My guess would be that SIMD wouldn't improve this piece of code, because all data is touched only once and the bottleneck is memory.
1GB in .25 seconds = 4GB in 1 second. Kind of a simplistic takeaway considering the article's title.
Reading into a reasonable buffer size would likely speed things up.
Also, multithreading.
Worth trying like all these things, but I'm not convinced you'd see a different, go ahead and prove me wrong!
It runs 2.5 sec first time when it reads file from SSD and just 0.6 sec second time when contents of the file is already in the OS disk cache.