Ticket #45123

Optimize action_by_number()

Open Date: 2022-07-17 15:31 Last Update: 2022-08-05 09:05

Reporter:
Owner:
Type:
Status:
Closed
Component:
MileStone:
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
2

Details

Profiling run showed that now action_by_number() is a major performance bottleneck (took over 10% of the run time).

In addition to the function call overhead, it does work that's redundant for most callers: it's called A LOT inside action_iterate(). The action_iterate() iterates over valid actions only, so no point to do all that checking of action validity in those action_by_number() calls.

There's several ways we could rework this. One is to inline the function, trusting that the compiler then detects what's redundant in each call, and optimizes. In a quick test with inlined action_by_number(), there was a huge improvement in the total run time of an autogame.

Ticket History (3/6 Histories)

2022-07-17 15:31 Updated by: cazfi
  • New Ticket "Optimize action_by_number()" created
2022-07-17 16:02 Updated by: cazfi
  • Owner Update from (None) to cazfi
  • Resolution Update from None to Accepted
  • Milestone Update from (None) to 3.0.3 (closed)
2022-07-24 20:54 Updated by: cazfi
Comment

3.0.3 release is coming sooner than earlier expected -> don't want to take unnecessary risks of regressions (with the limited time that this would be tested in branch).

2022-08-05 09:05 Updated by: cazfi
  • Status Update from Open to Closed
  • Resolution Update from Accepted to Fixed

Attachment File List

Edit

Please login to add comment to this ticket » Login