Right now the FurnitureStaticSrv and FurniturePhysicsSrv are directly connected to the Helper.signal_broker.player_y_level_updated signal. The player emits this signal every .5 seconds. This construction leads to almost 6000 calls to FurnitureStaticSrv._on_player_y_level_updated in one frame when walking around in a city.
I suggest connecting the signal to the FurnitureStaticSpawner instead and have it update the visibility of furniture in bulk. We can most likely do this in a thread. We could also check for the distance in y level from the player's y level and see if it really needs updating when the furniture is 2 or more y levels higher then the player and already hidden on the previous check.
In the case I observed, we can win a maximum of 5 ms with some optimization
Right now the FurnitureStaticSrv and FurniturePhysicsSrv are directly connected to the Helper.signal_broker.player_y_level_updated signal. The player emits this signal every .5 seconds. This construction leads to almost 6000 calls to FurnitureStaticSrv._on_player_y_level_updated in one frame when walking around in a city.
I suggest connecting the signal to the FurnitureStaticSpawner instead and have it update the visibility of furniture in bulk. We can most likely do this in a thread. We could also check for the distance in y level from the player's y level and see if it really needs updating when the furniture is 2 or more y levels higher then the player and already hidden on the previous check.
In the case I observed, we can win a maximum of 5 ms with some optimization