perf: stream the mapping file straight into the index - #48
Merged
Conversation
build_index used to deserialise the whole ~9 MB document into an intermediate HashMap of all ~77k source entries (each with its own inner map) before extracting the ~12k targets it actually needs -- about 33 MiB of transient allocations per refresh, which glibc then retains as idle RSS. A streaming serde visitor now folds keys directly into the four index maps and discards everything else as it goes.
Every index entry carried a Vec<String> that always held exactly one "sN" key, which lookups then re-formatted or re-parsed. Seasons are now parsed to u32 once at build time, dropping two heap allocations per entry in each direction and simplifying both lookup sites. Behavior note: a hypothetical scope like "s1e5" previously never matched a season search (exact string compare) but now parses as season 1; a survey of the live mappings file shows all 9,653 scopes are plain "sN", so no practical change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Replace full serde Value deserialization with custom visitor to save memory from useless json keys and values.