Page MenuHomeWildfire Games

Optimize the event broadcast
ClosedPublic

Authored by nani on Feb 16 2020, 1:25 PM.

Details

Summary

Currently when CGUIManager::SendEventToAll is called it sends the event recursively to all gui objects whether they have set a script handler for that event or not. This diff optimizes this so only those that have it set are called.

Profiling information: in my case, on average, I saw the gui tick time go down from 1.5 msec/frame to 0.6 msec/frame while in session, so about 2x the performance.

Should be easy to validate the code is correct as the changes are pretty simple.

The only possible concern could be that now the script handlers may not be called on the same order as there were called previously.

Test Plan

Apply patch, test all the GUI still works as before.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
/ps/trunk
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 11143
Build 19870: arc lint + arc unit

Event Timeline

nani created this revision.Feb 16 2020, 1:25 PM
bb added a subscriber: bb.Nov 14 2020, 10:31 PM

The order of calling is ambiguous anyway, so changing it is fine.

Tested on several maps, don't see a 2x improvement on my system, more like 1.5x or so, still an improvement and saving a 0.5ms every turn when having units selected seems worth it to me.

source/gui/CGUI.cpp
282

double space

bb accepted this revision.Nov 14 2020, 10:33 PM
This revision is now accepted and ready to land.Nov 14 2020, 10:33 PM
This revision was automatically updated to reflect the committed changes.