This repository has been archived by the owner on Oct 26, 2024. It is now read-only.
perf(YouTube): Reduce memory requirement for prefix tree searching #501
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.
Modified the prefix search to use a variable sized array which reduces memory usage.
Before this PR:
LithoFilterPatch: Using: 8 identifier filters (1 KB), 71 path filters (47 KB)
This PR:
LithoFilterPatch: Using: 8 identifier filters (1 KB), 71 path filters (5 KB)
Overall memory was already low. But the main benefit is less cpu cache churn, since it no longer loads cache lines that are mostly null.
On first startup it does require rehashing the node array as the filter patterns are added, but that takes 2 milliseconds total on a modern device (and that 2ms is only required once)
For reference, here is the rehashing the default litho filters go thru on app startup: