Skip to content

Improve memory usage of Live.getLastVisitDetails #23234

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

Merged
merged 1 commit into from
Apr 17, 2025
Merged

Conversation

mneudert
Copy link
Member

Description:

The data table filter used in the Live.getLastVisitDetails API is consuming a lot of unnecessary memory.

This happens because all actions for all visits are fetched at once and then enriched to populate the visit information. As the old actions list is not cleaned up, this leads to a nearly full duplication of the memory requirement during iteration.

With the actions are already being indexed by visit, it should be safe to remove them from the list when iterating over the visit.

The peak memory usage for the data table filter goes down by up to 45%, if actions are not filtered or limited in any way. The peak memory usage for the complete request though will not go down that much, as the peak is later growing e.g. during output rendering. Though it should not be unexpected to get more than 10% total reduction for the complete request.

Review

@mneudert mneudert added the Stability For issues that make Matomo more stable and reliable to run for sys admins. label Apr 16, 2025
@mneudert mneudert added this to the 5.4.0 milestone Apr 16, 2025
@mneudert mneudert requested a review from a team April 16, 2025 17:22
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

Nice catch!

@sgiehl sgiehl merged commit d27434c into 5.x-dev Apr 17, 2025
26 of 27 checks passed
@sgiehl sgiehl deleted the dev-18708-live-memory branch April 17, 2025 07:49
caddoo added a commit that referenced this pull request May 2, 2025
* Cherry pick ubuntu-24.04 update excl. submodule update (#23097)

* Update expected test results

* Ensure login username is provided as string value (#23117)

* Prevent automated linking in emails (#23248)

* Prevent automated linking in emails

* prevent linking on some more elements

* add some tests

---------

Co-authored-by: caddoo <1169490+caddoo@users.noreply.github.com>

* Improve handling of prefixUrl parameter in API.listAllMethods (#23247)

* Fix escaping in realtime report (#23245)

* Ensure all translations required for password confirmation are always loaded (#23176)

* Suppress errors when trying to access javaEnabled property (#23161)

Co-authored-by: caddoo <matthew.caddoo@gmail.com>

* Ensure to discard campaign names with invalid type (#23229)

* Prevent concurrency when removing sites (#23230)

* Prevent warning when no email is set for current user (#23228)

* Improve region name fetching (#23235)

* Unset actionsByVisitId after consumption (#23234)

* Use https URLs (#23072)

* Use https URLs

* Build vue files

* use matomo.org instead of piwik.org in some links

* updates expected UI test file

---------

Co-authored-by: innocraft-automation <innocraft-automation@users.noreply.github.com>

* Update screenshot

* Tweak regex for host checks

---------

Co-authored-by: Marc Neudert <marc@innocraft.com>
Co-authored-by: Stefan Giehl <stefan@matomo.org>
Co-authored-by: caddoo <1169490+caddoo@users.noreply.github.com>
Co-authored-by: caddoo <matthew.caddoo@gmail.com>
Co-authored-by: innocraft-automation <innocraft-automation@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stability For issues that make Matomo more stable and reliable to run for sys admins.
Development

Successfully merging this pull request may close these issues.

2 participants