Skip to content

Lazy-load res.items instead of caching entire table (~20MB savings)#12

Open
christopherkmoore wants to merge 1 commit into
DiscipleOfEris:masterfrom
christopherkmoore:fix/lazy-load-res-items
Open

Lazy-load res.items instead of caching entire table (~20MB savings)#12
christopherkmoore wants to merge 1 commit into
DiscipleOfEris:masterfrom
christopherkmoore:fix/lazy-load-res-items

Conversation

@christopherkmoore

Copy link
Copy Markdown

Summary

  • Removes items = res.items global assignment that materializes the entire Windower item database (~20MB)
  • Replaces the single usage (line 324) with direct res.items[packet.Param] on-demand lookup
  • Saves ~20MB RAM per client, ~120MB+ for multiboxers running 6+ instances

Details

items = res.items at 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

  • Verified FastFollow functions normally — following, zoning, item usage pause all work
  • Memory usage drops from ~25MB to ~1.3MB idle

`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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant