Summary: optimise time needed to creating a savegame
                 Project: Freeciv
            Submitted by: syntron
            Submitted on: Mi 16 Nov 2011 22:28:24 CET
                Category: general
                Priority: 3 - Low
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 



from a message to the developer list (mail by Michal Mazurek):

> My sparc64 502mhz is taking 4 minutes now to /save a game. I
> tried poor mans optimization and inlined a couple of
> functions. I tested it on a 8x3400mhz intel i7. The test .serv
> was loading the game, and saving it 10 times. I managed to
> only go down to 11.76 from 13.56 seconds, that's not very
> much. Most of the time is spent doing real stuff, so i guess
> 500mhz is not adequate to run games with max map. About 5
> seconds of that time is just starting the server and loading
> the map.
> The function tile_index is called 495681563 times, I cant see
> how this can be cut down.
> sg_save_player_vision is called 370 times and takes most time,
> 12%. But it seems to be doing real stuff, also hard to cut
> down. And even if it is cut down, it's still only 12%.
> A decent computer saves the game rather fast, so I just guess
> my computer is just too old to run longturn games.

One thing to speed up saving a game would be a better handling of the saving
each part of the map. In sg_save_player_vision() the macro SAVE_MAP_CHAR is
called several times. Each (!) time it iterates over all tiles (= get tile
from x, y coordinates) and saves only one part of the vision map definition
(terrain, resources, (owner), specials, bases, update time). If this could be
changed to one loop it would help.

Similar optimisation could be done for sg_save_map_known(); perhaps even all
in one loop? (loop 1: y = lines; inner loop: x values; each part to be

> However, I think that inlining functions like:
> int player_slot_count(void)
> {
>   return (MAX_NUM_PLAYER_SLOTS);
> }
> would actually not only be faster, but also take less space.

I not sure that the rules are for inlining functions. In coding style only
the use of inline functions instead of macros is stated.


Reply to this item at:


  Nachricht geschickt von/durch Gna!

Freeciv-dev mailing list

Reply via email to