fluidd-core / fluidd

Fluidd, the klipper UI.
https://docs.fluidd.xyz
GNU General Public License v3.0
1.42k stars 434 forks source link

Performance: All console history entries are re-rendered #147

Closed Piezoid closed 3 years ago

Piezoid commented 3 years ago

When the console history is full (1000 entries) new entries are displayed very slowly and the frame time reach ~1s on Chrome and Firefox. This is most obvious with big outputs (DUMP_TMC or tuning tower with a spiralized contour) Profile screeshot

Reducing config.CONSOLE_HISTORY_RETENTION to 100 solved the problem, confirming the O(n) render time theory. The DOM view shows that all entries and their container gets updated (pink flash) each time a new one is added.

I've tried to key the ConsoleEntryWidgets v-for with a monotonic key, instead of the dequeue's indices, to help the diffing algorithm avoid shifting the content of all entries. This allows to use v-once inside console entry, which was not working before because of the content shift. It helped a bit (frame time dropped to 400ms), but still very slow.

Draft patch ```diff diff --git a/src/components/widgets/ConsoleEntryWidget.vue b/src/components/widgets/ConsoleEntryWidget.vue index d49f9eb..075c6ab 100644 --- a/src/components/widgets/ConsoleEntryWidget.vue +++ b/src/components/widgets/ConsoleEntryWidget.vue @@ -1,5 +1,5 @@