9 ms·
> The MPV patch of v0.1 is without a doubt build 36 (e16bab8). The "Cripy optimization" turns status bar percentage rendering into a noop if they have not chang
by gwern 2y ago
> The MPV patch of v0.1 is without a doubt build 36 (e16bab8). The "Cripy optimization" turns status bar percentage rendering into a noop if they have not changed. This prevents rendering to a scrap buffer and blitting to the screen for a total of 2 fps boost. At first I could not believe it. I assume my toolchain had a bug. But cherry-picking this patch on PCDOOMv2 confirmed the tremendous speed gain.
Good example of how the bottlenecks are often not where you think they are, and why you have to profile & measure (which I assume Viti95 did in order to find that speedup so early on). The status bar percentage?! Maybe there's something about the Doom arch which makes that relatively obvious to experts, but I certainly would've never guessed that was a bottleneck a priori.
- robocat 2y agoExample: "Our app was mysteriously using 60% CPU and 25% GPU. It turned out this was due to a tiny CSS animation [of an equaliser icon]" https://www.granola.ai/blog/dont-animate-height https://www.granola.ai/blog/dont-animate-height
- pinoy420 2y ago[dead]
- ericmcer 2y agoWhy was the solution to optimize the animation instead of... using a static asset?
- moffkalast 2y agoWe paid for the whole CSS spec and we're gonna use the whole CSS spec.
- joquarky 2y agoThis, but for everything wevdev-related in the past ten years.
- jonas21 2y agoBecause it provides an indication that the app is receiving your voice input?
- teaearlgraycold 2y agoI think they're suggesting an animated PNG or GIF.
- kccqzy 2y agoOr even better an animated SVG. Put it inside an <img> tag with a known width and height.
- LegionMammal978 2y agoI'd be very surprised if SVG animations don't use substantially the same rendering paths that CSS animations do. In fact, if anything, I'd expect CSS animations to receive more time and attention from browser devs than the old SMIL elements and attributes, to whatever extent that they aren't equivalent internally.
- teaearlgraycold 2y agoSVGs are usually animated with CSS.
- kccqzy 2y agoYeah but the crux of the problem is when height is animated the browser needs to redo the layout. Here the animation is contained entirely within an <img> tag with known width and height.
- Joe_Cool 2y agoThat's something I'd use a canvas or even a SVG for. SVG FFT Analyzer sound like a fun project. Oh, looks like I'm way late: https://cprimozic.net/blog/building-a-signal-analyzer-with-modern-web-tech/ https://cprimozic.net/blog/building-a-signal-analyzer-with-m...
- teaearlgraycold 2y agoThat would be more optimized for sure. But it wouldn't be scalable and would take more work to create than what looks like a pretty simple change.
- rplnt 2y agoI remember Slack eating up my CPU when it had to display several animanted emojis at once. Use some 20+ emojis and the intel mb pro couldn't handle it. Luckily they knew and there was an option to disable the animation. Now I have no idea if they fixed it since or it is one of those things that was "fixed" by M1. Would like to see a write up on how it's even possible to achieve that when PCs from 20-30 years ago had no issue with such task.
- throwup238 2y ago> Would like to see a write up on how it's even possible to achieve that when PCs from 20-30 years ago had no issue with such task. Electron.
- rplnt 2y agoBut that's just a browser, right? I'm pretty sure my browser in 2005 could display dozens of gifs. There must have been a series of decisions by devs to do it in some super convoluted way. I can see each emoji being an iframe with a full react app doing the animation. But even that should be fine? Maybe?
- throwup238 2y agoIt's "just a browser" in the same sense that the Linux kernel and GNU are "just an operating system". It's one of the most complex pieces of software - perhaps even human designed systems - ever to exist and we're using it to render a few polygons and drop shadows because the C++ committee made a bunch of mistakes decades ago so now our webdevs are mortally afraid of CMake and Qt/QML. Or GTK. Or whatever. Pretty much the only people that seem to put out native GUI tools in any significant quantity are Apple developers. The tradeoffs that Blink and V8 engineers have made to support the entirety of the internet and the morass of web development precludes efficient use of resources for simpler purposes, like rendering an animation. After all, there a billion React hooks and ad tracking scripts to optimize, otherwise bounce rates will increase.
- 2y ago
- grrowl 2y agoOr more recently, NPM's infamous "Progress bar noticeably slows down npm install #11283" issue [1]: https://github.com/npm/npm/issues/11283 https://github.com/npm/npm/issues/11283
- guappa 2y agoA thing I discovered by myself when I was a teenager: do not update progress bars on every loop.
- Cthulhu_ 2y agoThere's a lot of things front-end developers (be they web or graphical terminal) can learn from the game development world. I can recommend playing with e.g. Pico 8 sometime, it's artificially constrained so you have to work with the limitations instead of do the usual relatively naive work. It's LUA coding so it shouldn't be a problem for JS developers, assuming they don't mind working in a 20 column code editor (or thereabouts).
- account42 2y agoGames developers are not magically safe from the progress bar mistake.
- conductr 2y agoI think it’s more so important to get familiar with loop/event based programming. Most of my experience is in the request/response mindset of web requests so when I try out game dev, arduino dev, C# desktop apps, etc I find my mental model has to shift drastically Loops occur so fast it’s pretty standard to have to put some throttling logic in the code which I’ve never had to do in web dev except perhaps the document.ready statement in JavaScript to make sure the dom has been loaded.
- accrual 2y agoSame here. I often implemented like this, where n was some reasonable value: if iteration % n === 0: update_progress()
- emmanueloga_ 2y agoThis is why it pays out to turn on "Paint Flashing" [1] in the web console, even if just from time to time. -- 1: https://web.dev/articles/simplify-paint-complexity-and-reduce-paint-areas#use_chrome_devtools_to_quickly_identify_paint_bottlenecks https://web.dev/articles/simplify-paint-complexity-and-reduc...
- moffkalast 2y agoMe, who already renders a canvas on the whole page so it highlights the whole thing constantly: "Hmm yes the painting here is made out of painting."
- emmanueloga_ 2y agoThat's cool, I don't know how popular canvas heavy apps are these days, what kind of apps are you working with? I used to work on a set top box app, and for some of the features, replacing the whole page with a single canvas was the only way to get steady FPS.
- ortsa 2y agoThis reminds me of having to go into spotify's package files to track down their version of this animation (an animated svg of a bar chart) and kill it, because it would destroy performance on my PC so badly that it was affecting other programs, causing hitches and freezes. The animation's still there — and my PC is better now, so it doesn't stutter — but I'm willing to bet it's still burning waaay too many watts, for something so trivial.
- Dwedit 2y agoCSS animations make Flash look efficient by comparison.
- barbariangrunge 2y agoAs a gamedev, those slowdowns are common. Ui rendering, due to transparency, layering and having to redraw things, and especially from triggering allocations, can be a real killer. Comparing old vs new before allowing it to redraw is really helpful. I found layers and transparency was a killer in css as well in one project, but that was more about reducing layers there
- lomase 2y agoDrawing to the screen is a IO operation, is going to be slow.
- aeyes 2y agoHe ported the optimization from the Crispy Doom fork. Since this is one of the first changes in the repo I bet that this was a known issue at the time.
- pjs_ 2y agoReminds me of the incident where npm was 2X slower than it should have been because of the fancy terminal progress bar: https://news.ycombinator.com/item?id=10974929 https://news.ycombinator.com/item?id=10974929
- qingcharles 2y agoThe original Doom must have been heavily profiled by id though, surely? Obviously there is a bunch of things that were missed, but I was in game dev at Doom time and profiling was half the job back then.
- fabiensanglard 2y agoWhat tools did you have in 1993? From what I understood, id Software used NeXT because the tooling was not up to the task.
- qingcharles 2y agoYikes. Now you're pushing my memory. I believe there was a profiler built into Visual Studio and we had some external tool, too. We had some sort of system set up with serial cable to debug and profile. The EXE would download onto our test PC next to us. Problem for id is that you have no sane way of profiling the DOS port on NeXT.
- fabiensanglard 2y agoVisual Studio? The first released Visual Studio (Boston) was released in 1997. Doom was developed during 1993 :P !
- masfuerte 2y agoHe may well be thinking of Microsoft Visual C++, which dates back to 1993 and evolved into Visual Studio. It had a profiler. https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B
- Narishma 2y agoDoom was developed on NeXT machines, not Windows.
- ognarb 2y agoI had a similar case when I work on a Matrix client (NeoChat) and I and the other devs were wondering why loading an account was so slow. Removing the loading spinner made it so much faster, because the animation to render the loading spinner uses 100% cpu.
- jiggawatts 2y agoA common one for server apps is logging, especially to the console. It’s far more expensive than people assume and in many cases is single-threaded. This can make logging the scalability bottleneck!
- rcxdude 2y agoLogging to a 'serial' console can stall the whole kernel, wrecking latency, and this can easily show up in VMs since a lot of them emulate a lowest-common-denominator UART inerface as the kernel console.
- ahoka 2y agoI remember setting a server’s console baudrate in EFI to its higher setting improved boot times, hehe.
- slavboj 2y agoAt one point the bottleneck to the Siri iOS client was rendering the animated glowy ball.
- PlunderBunny 2y agoBack at the turn of the century we found that a performance sensitive part of our WIN32 app was adversely affected by reading a setting from an ini file - in Windows 2000, it was significantly slower than on earlier versions of Windows. The setting was just to determine whether to enable logging for that particular part of the app.
- Cthulhu_ 2y agoIronically, it was rumoured Monster Hunter Wilds gets a performance boost if you fix a typo in an .ini file (https://steamcommunity.com/app/2246340/discussions/0/596268233570403298/ https://steamcommunity.com/app/2246340/discussions/0/5962682...?), but that was debunked (the typo is restored when reopening the game, the .exe uses the same typo so it's not that the wrong value is being read).
- on_the_train 2y agoI'm currently at the second job in my life where updating the progress bar takes up a tremendous percentage of the overall performance. Because our "engineers" have never used a profiler. At a large international tech giant :(
- Cthulhu_ 2y agoI do understand it though, at bigger companies you're less likely to want / need to worry about smaller things. Of course, I'm willing to bet money that they implemented a progress bar themselves instead of using an off-the-shelf one.
- on_the_train 2y agoMFC Progress bar. Like it's 1999
- int_19h 2y agoWin32 already had a stock progress bar control in 1999, though. ~
- deleted 2y ago[deleted]
- inDigiNeous 2y agoReminds me of the performance optimization somebody discovered in Super Mario World for SNES, where displaying the player score in was very inefficient, taking about 1/6 of the frametime allocated. "SMW is incredibly inefficient when it displays the player score in the status bar. In the worst case (playing as Luigi, both players with max score), it can take about a full 1/6 of the entire frame to do so, lowering the threshold for slowdown. Normally, the actual amount of processing time is roughly proportional to the sum of the digits in Mario's score when playing as Mario, and the to the sum of the digits in both players' scores when playing as Luigi. This patch optimizes the way the score is stored and displayed to make it roughly constant, slightly faster than even in the best case without." https://www.smwcentral.net/?p=section&a=details&id=35746 https://www.smwcentral.net/?p=section&a=details&id=35746
- smat 2y agoWhile this gives an impressive boost in performance, it also means that frametimes are around 10% longer when the status bar has to be updated. Overall this can mean that in some situations the game feels not as smooth as before due to these variations. Essentially when considering real time rendering the slowest path is the most critical to optimize.
- flykespice 2y agoYep, in a real situation the player would be constantly moving around collecting hp/ammo/weapon, losing health/ammo to monsters... all these would cause the status bar to be frequently updated. I don't think the benchmark accounts that.
- RankingMember 2y agoMy favorite example of this is the GTA Online insane loading time issue that ended up being due to poor handling of a 10MB json file (and was finally tracked down by someone outside their org). Took a 6 minute load time down to just under 2 minutes: https://nee.lv/2021/02/28/How-I-cut-GTA-Online-loading-times-by-70/ https://nee.lv/2021/02/28/How-I-cut-GTA-Online-loading-times...