Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seek and destroy main memory leak #1444

Merged

Conversation

rafaellehmkuhl
Copy link
Member

@rafaellehmkuhl rafaellehmkuhl commented Nov 11, 2024

I performed about a week of testing with Cockpit to learn more about its performance issues.

A detailed report can be found here, but I will make a resume below.

The main leak

I could find that we indeed have a big memory leak that causes the application to become slow after about 20 minutes and to crash after around an hour (depending on the computer specs). After a lot of tests I could determine that this leak is caused by a v-tooltip component that is used in the expanded list of the Alerter.vue widget. This component is instantiated for every alert in the list, and is never garbage-collected, so for every new alert added to the list, a series of zombie components are created and left there forever. This PR replaces that component, effectively removing the main memory leak.

Before:
alerter-with-v-tooltip

After:
alerter-without-v-tooltip

Other leaks

I could also find that we have smaller memory leaks (with unknown sources) that grow very slowly, without interfering in most (99%?) user sessions, and that we have a concentrated memory leak when the joystick configuration page is open.

Future work

This PR only fixes the main memory leak (from the Alerter.vue widget), but a following PR should be done fixing the problem in the joystick configuration page as well, as it affects every user that opens that view.

We should also eventually have a better solution than the title attribute to replace the buggy tooltip, as the attribute does not work on mobile and takes a somewhat long hovering time to shown, degrading the UX.

Result

With this PR, the user can now effectively run Cockpit for hours without it becoming slow or crashing.

@rafaellehmkuhl rafaellehmkuhl force-pushed the seek-and-destroy-memory-leak branch from df5de03 to 62c6ed0 Compare November 12, 2024 15:30
The `v-tooltip` attribute-based component has a bug: it is never eliminated once instantiated, and as the alerts list is regenerated for every new alert, the tooltip component was accumulating in an exponential way, leading to a crash in the whole application.

For the moment a simple `title` attribute is used, but it's not an ideal solution, as it takes some hovering time to be activated. A better solution involves creating/importing a new tooltip component that doesn't have the same bug or to expand the alert space to fit the text during hovering.
@rafaellehmkuhl rafaellehmkuhl force-pushed the seek-and-destroy-memory-leak branch from f8965d5 to e8dee51 Compare November 18, 2024 18:10
@rafaellehmkuhl rafaellehmkuhl changed the title Seek and destroy memory leak problem [part 1?] Seek and destroy memory leak problem [part 1] Nov 18, 2024
@rafaellehmkuhl rafaellehmkuhl marked this pull request as ready for review November 18, 2024 19:12
@rafaellehmkuhl rafaellehmkuhl changed the title Seek and destroy memory leak problem [part 1] Seek and destroy main memory leak Nov 18, 2024
Copy link
Contributor

@ArturoManzoli ArturoManzoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome investigative job!

Cockpit is running great now

@ArturoManzoli ArturoManzoli merged commit 00a732f into bluerobotics:master Nov 21, 2024
10 checks passed
@rafaellehmkuhl rafaellehmkuhl deleted the seek-and-destroy-memory-leak branch November 25, 2024 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants