Improve memory usage of Live.getLastVisitDetails #23234
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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