DeckerMMIV/FarmSim_Mod_WheelLanes

Possible tweaks for MP performance

Closed this issue · 5 comments

Hi,

Firstly I have to admits, that this is most comprehensive mod of WheelLanes. However as written in source code it cause FPS drop in MP.
What I observer line 247 is causing constantly 15-20% of total scripts calculations.

Is there a chance to optimize MP performance. We use this mod all time, so can contribute to tests.

Line 247? - Well, it is the for-loop which iterates through the number of "wheels touching ground", so when there are many wheels on active vehicles/equipment, there is a lot of network-events being sent from server to clients.

Try this - Comment out the lines 74 & 101:

74:    -- and self.isServer             -- Only on server
101:   --    g_server:broadcastEvent(WheelLanesEvent:new(cuttingAreasSend));
       ^^ 

Doing that will cause the script to not send any network-events from the server to clients.

Instead it will cause all clients (and the server) to locally calculate the 'wheels areas of destruction', but only if the wheel(s) hasGroundContact - which in FS2013 is a server-only variable, so it might not work correctly on clients.


Thinking out loud...

Another possibility could be to have the server not send the 'wheels areas', but instead just the vehicle-id and then let the clients locally calculate the 'wheels areas' (disregarding if they have ground contact or not.) - This would reduce the size of the network-event packages being sent, but still not the iterations required in the WheelLanesEvent.destroyFoliageLayers() method.

Even yet another method could be to 'even out' the required number of calls to setDensity...() over several rendering-frames, instead of just one. But this will probably be impossible to keep in sync.

Or figure out if there is a possibility to reduce the number of calls to GIANTS' game-engine's setDensity...() API methods, because of the mod's requirement of not destroying the grass fruit-type and the specialty with potato & sugarBeet.

Unfortunately commenting out line 74 & 101 indeed caused lack of wheel destroying effects on client side.
Other suggestions are out of my coding abilities, which are just basic.

@Dzi4d3k - Would it be possible for you to test my recent v0.8.0-BETA changes in multiplayer?

@DeckerMMIV
Of course, with pleasure. We will test it and I'll back with results.

Its been a while since last update, with quick thought I can say that there is a lot improve in performance. However because of summer time we didn't manage yet to do "massive lag test" what we calling to 5-6 people cutting, tedding, baling grass on one filed. On previous version it was a nightmare with 10-15 FPS.
I'll get back if I have update in mean time I have possibly another issue #2.