Complete.Org:
Mailing Lists:
Archives:
freeciv-dev:
August 2004: [Freeciv-Dev] (PR#9802) generic_city_refresh speedup via caching |
[Freeciv-Dev] (PR#9802) generic_city_refresh speedup via caching[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9802 > The major cost in the CM (>50%) is generic_city_refresh ; that's why we maintain all the fancy caches which distribute assumptions about game rules. Looking at why this one function was so slow, I discovered it's because it computes a bunch of stuff that doesn't change across calls withing the CM -- which buildings exist, distance to the capital, etc etc. This patch allows the CM to do: (1) precompute various things, once per cm_query_result. (2) quickly do the update, assuming everything was pre-computed, dozens of times. And it does so transparently to almost all calling code. It creates a new opaque field, that unfortunately citytools.c needs access to, so I created common/citycache.h (attached seperately since I don't know how to make cvs diff create it). I've played almost a full game without problems that I could discern (except one I fixed), but this does change how some fairly fundamental calculations are done, so some scrutiny is in order. I did a cvs update today to check, but it seems that even a clean build has an assertion failure as soon as I build a city, so all I can say is that this patch compiles, and once ran. The patch reduces the CM time by about 10%. After this, the main remaining cost of quick_city_refresh is evaluating the tiles, which could also be cached (that would be for a later patch).
city_quicker_refresh.diff
citycache.h
|