Lazy-load res.items instead of caching entire table (~20MB savings)#12
Open
christopherkmoore wants to merge 1 commit into
Open
Lazy-load res.items instead of caching entire table (~20MB savings)#12christopherkmoore wants to merge 1 commit into
christopherkmoore wants to merge 1 commit into
Conversation
`items = res.items` at module level forces the entire Windower resource item database to materialize in memory (~20MB). This global is only used once (line 324) for a single item lookup when detecting item usage to pause following. Replace with direct `res.items[packet.Param]` access on demand. Cold lookup cost is ~0.2ms which is imperceptible for this infrequent event. Saves ~20MB RAM per client, ~120MB+ for multiboxers.
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.
Summary
items = res.itemsglobal assignment that materializes the entire Windower item database (~20MB)res.items[packet.Param]on-demand lookupDetails
items = res.itemsat module load time assigns the full resource items table to a global, forcing Windower's lazy-loading resource system to fully materialize all ~10,000+ item entries into memory.This global is only accessed once — when detecting item usage to pause following. A direct
res.items[packet.Param]lookup is functionally identical and only loads the single entry needed.Benchmarked cold
res.items[id]lookups at ~0.2ms per access, which is imperceptible for this infrequent event (item usage during follow).Testing