reduce cpu and gpu usage#1029
Conversation
… RAF dispatches, memoizing expensive computations, guarding hidden-tab animation loops, and eliminating unnecessary re-renders and event listener churn.
|
Hi @Fury7425 How exactly did you measure / profile the performance improvements? I don't really see a significant difference before / after and I'm a bit worried that this will just increase the code complexity without any noticeable benefit. Thanks a lot for checking & for the contribution! Timon |
|
I basically installed msi afterburner and rivatuner to get like the games fps and cpu gpu usage in real time but I just made it detect rapidraw also got the data and that's what I saw on my system. This is a very small optimization in performance cause I really tried to not mess with the code much like all the changes except the keybinds are basically one or two letter differences. So it's really upto you to see if the little bit of a better experience on lower end and older hardware is worth it. I'd say why not but you are the maintainer and developer so yeah. |
|
Honestly I'd recommend accepting except the waveform and keyboards. Idk why but now looking at it I forgot to fix the ais code to update the waveform in real time cause claude for some reason edited it so that it only updats after the change is made. and the keybind change did have large amounts of changes. But that's me and I made the pr so 🤷♂️ |
|
BTW I forgot to save the results so here's a quick video recording to show you the results. https://quickshare.samsungcloud.com/75aPDCfeFNft |
updated the app to use less gpu and a bit less cpu while editing. (may feel a little bit laggy cause its not updating as soon as possible but probably enough although that is subjective)
upto -10% usage on my igpu when rapidly changing the values. and +3% to -8% usage on cpu.
Tested and didn't really see breaking (DIsclaimer: i dont really use keyboard shortcuts so idk if that broke)
Test Configuration:
AI Disclaimer:
src/hooks/useHistoryState.tsxJSON.stringifyequality check withshallowEqual()(one-level key comparison)src/components/ui/Slider.tsxonChangeRefdispatch batched through RAF viapendingDispatchRef+dispatchRafRef; flushed immediately on pointer uponChangefires at most once per frame instead of on everypointermoveeventsrc/components/panel/editor/Waveform.tsxHistogramViewpath computation (Math.max+map/join) wrapped inuseMemo([red, green, blue])src/components/adjustments/Curves.tsxgetCurvePath(points)result wrapped inuseMemo([points]); component wrapped inReact.memo()src/components/adjustments/Basic.tsxReact.memo()src/components/adjustments/Color.tsxReact.memo()src/components/adjustments/Details.tsxReact.memo()src/components/adjustments/Effects.tsxReact.memo()src/hooks/useKeyboardShortcuts.tsxpropsRefpattern; dep array is now[]src/hooks/useThumbnails.tsxsize === 0guard at top of 150ms intervalArray.from/filterskipped entirely when visible queue is empty; interval self-cancelssrc/App.tsxcomputeWaveform: !!isWaveformVisible && !dragging