Skip to content

Performance issues when lots of players join a server #25

Description

@nicholasgower

This performance profile from a multiplayer server with many players reveals a performance issue in this mod when many players join a server, consuming about 0.1 ms/tick. https://drive.google.com/file/d/1QleU9Hl7DZJnavPceqR_qiIi0ZhE7F0O/view?usp=sharing

Image

The save in question: https://drive.google.com/file/d/1EIpE8g6PuJJeyk02Q9vlg914lZ54Mv9s/view?usp=sharing

The root cause is in the mod's on_tick event:

script.on_event(defines.events.on_tick, function(event)

The problem is that the mod runs an on_tick event that loops through every player and attempts to update the player's gui. The size of this loop could be reduced by instead looping through a list of players that currently have a gui opened. Using on_gui_opened and on_gui_closed events, you can create a storage table that contains a list of all players that currently have a gui opened. Looping through this smaller list during on_tick would yield great performance improvements on large servers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions