jazzfool / reclutch

Rust UI Core
Other
157 stars 4 forks source link

Change example code to prevent extremely high CPU load #7

Closed fogti closed 4 years ago

fogti commented 5 years ago

The example code runs with 100% CPU load on one core. Trivial changes drop this to ~80%.

fogti commented 5 years ago

(currently not fixed:) I experimented with the example code and (for me) the slowest operation was resizing. This should be fixable via delaying the window updates by a small time and only applying the last window size to prevent the creation+destruction of dozens of window surface instances.

fogti commented 5 years ago

it would be advisable to catch the Init event and perform the first rendering before the first resize event comes in.

fogti commented 5 years ago

could it be possible to cache parts of the text rendering?

jazzfool commented 4 years ago

Well ideally the rendering would run in a different thread entirely, which would also solve the resizing problem. Though, we can definitely "rate-limit" the resizing somehow. Although it is peculiar you have such high CPU usage, I'm seeing a max CPU usage of 2% and ~5% GPU. Could you possibly profile the CPU calls?

As for text caching, Skia already caches a lot of the text rendering stack, either with a typeface store or with the OS glyph cache, and we're also already storing the result of the font match from font-kit in the counter example.

Overall, I'll see what I can improve with the performance in the counter example.