MantisBT - VCMI
View Issue Details
0003028VCMIAI - Adventure Mappublic2018-12-16 13:482018-12-30 20:41
Warmonger 
Nullkiller 
normalminoralways
resolvedfixed 
1.next 
1.next 
0003028: Optimize CGameInfoCallback::getPlayerTeam
According to MSVS 2015 profiler, this little function uses 2% of all client time.

However, it has not much use, since player teams don't change often (if at all). Just make fixed player->team field.

Maybe update it only when player leaves the game, if ever.
No tags attached.
png Issue 3028.png (48,525) 2018-12-30 20:22
https://bugs.vcmi.eu/file_download.php?file_id=2970&type=bug
png
Issue History
2018-12-16 13:48WarmongerNew Issue
2018-12-16 17:40AVSNote Added: 0007698
2018-12-30 19:40AVSNote Added: 0007701
2018-12-30 19:40AVSStatusnew => resolved
2018-12-30 19:40AVSFixed in Version => 1.next
2018-12-30 19:40AVSResolutionopen => fixed
2018-12-30 19:40AVSAssigned To => Nullkiller
2018-12-30 20:21WarmongerNote Added: 0007702
2018-12-30 20:22WarmongerFile Added: Issue 3028.png
2018-12-30 20:24WarmongerNote Edited: 0007702bug_revision_view_page.php?bugnote_id=7702#r3547
2018-12-30 20:41AVSNote Added: 0007703

Notes
(0007698)
AVS   
2018-12-16 17:40   
getPlayerTeam could be optimized, but problem is not in getPlayerTeam itself, but in that it is called way to often (mostly from tile visibility checks). AI should cache FoW map locally and do not retrive it from callback every time.
(0007701)
AVS   
2018-12-30 19:40   
Optimized in https://github.com/vcmi/vcmi/pull/528 [^]
(0007702)
Warmonger   
2018-12-30 20:21   
(edited on: 2018-12-30 20:24)
Indeed, but you actually had to optimize 2 different AI functions where this call is used, and the list is not exhaustive. At least these were 2 main callers.
(The lambda in the screenshot comes from ExplorationNewPoint())

(0007703)
AVS   
2018-12-30 20:41   
See the PR, and my review. I`ve marked all known bottlenecks (I have profiler data too)