Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#3717 closed defect (fixed)

Optimize range queries

Reported by: mimo Owned by: mimo
Priority: Should Have Milestone: Alpha 20
Component: Core engine Keywords: patch
Cc: Patch:


Most of the time used by range queries is spent sorting (by id) entities which are in range, before checking that they fulfill the query requirements. Doing the sort after the filter drastically improves the performance. On a non visual replay with 2000 turns, Valgrind quotes 6.9% spent in PerformQuery before the fix, which is reduced to 4.0% with the patch.

Attachments (2)

fastSpatial.patch (1.8 KB ) - added by mimo 8 years ago.
commands-tutorial.txt (239.1 KB ) - added by fabio 8 years ago.
commands.txt used for the profile, for reference

Download all attachments as: .zip

Change History (7)

by mimo, 8 years ago

Attachment: fastSpatial.patch added

comment:1 by fabio, 8 years ago

I tested this patch against r17566, here is the graph of total time while replaying (simulation, not visual) the tutorial, the improvement is noticeable (although a couple peaks are slower). I also added for reference a19, it is faster than svn but has a different final hash, so probably not directly comparable. EDIT: ignore a19, the visual replay is indeed completely different.

Last edited 8 years ago by fabio (previous) (diff)

by fabio, 8 years ago

Attachment: commands-tutorial.txt added

commands.txt used for the profile, for reference

comment:2 by mimo, 8 years ago

Thanks fabio for the checks. I don't understand how the changes in the code could explain the differences in the spikes at 330 and 600. Could you rerun your profiles to check that these are reproducibles ?

comment:3 by fabio, 8 years ago

I tried it on a different, faster PC and there are no regressions. Sorry for for the annoyance and thanks for working on improving performance!

comment:4 by mimo, 8 years ago

Owner: set to mimo
Resolution: fixed
Status: newclosed

In 17573:

optimizes range queries, fixes #3717

comment:5 by mimo, 8 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.