In Rust, BaseNetworkable.clientEntities contains thousands of world objects (trees, ores, barrels, animals, players).
If you iterate all 15,000 entities every frame, your external overlay will drop to 20 FPS.
Multi-Threaded Entity Caching Solution:
- Spawn a dedicated background worker thread that iterates
clientEntitiesonce every 200ms. - Filter and store active players (
BasePlayer) and relevant loot in an atomic thread-safe double buffer. - The main render thread only reads the small cached array of ~30 nearby players at 144Hz.
Zero frame hitching, render overlay runs at solid 240 FPS!