patchFreeciv - Patches: patch #3058, optimise time needed to creating a...

Show feedback again

patch #3058: optimise time needed to creating a savegame

Submitted by:  Matthias Pfafferodt <syntron>
Submitted on:  Wed Nov 16 21:28:24 2011  
Category: generalPriority: 3 - Low
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Planned Release: Contains string changes: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Wed Nov 16 21:28:24 2011, original submission:

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 saved).

> However, I think that inlining functions like:
> int player_slot_count(void)
> {
> }
> 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.

Matthias Pfafferodt <syntron>
Project Member


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by syntron (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    No Changes Have Been Made to This Item
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup