Project

General

Profile

Actions

Feature #2502

open

Fastening map generation

Added by Paweł Nowak 5 days ago. Updated about 15 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Server
Target version:
Start date:
11/23/2026
Due date:
% Done:

0%

Estimated time:

Description

Generating a very large map takes a long time. On a map of 2,000,000
tiles with settings: (generator FRACTAL, mapsize FULLSIZE, size 2000,
other settings default) it took about 9 minutes on Debian on Intel(R) Core(TM) i5-10300H CPU @ 2.50GHz.

A perf profile of freeciv-server (build from git, -O2 -g) showed two
hot spots:

1. make_land(), with make_rivers() inlined, about 60% of the samples.
For every river attempt make_rivers() scans the whole map several
times (to build the blocked tile set from other road-like extras,
and again to apply the river). The number of rivers grows with the
map size, so the cost is about quadratic.
2. genlist_search(), about 25-30% of the samples. It is called from
assign_continent_flood() (mapgen_utils.c), which calls
tile_list_search() on its queue for every neighbouring tile.

The attached patch fix both without changing the result:

  • fasten_map_gen.patch

With it applied, generating the same 2,000,000 tile map takes
under 1 minute on the same computer.

Testing: built from git commit https://github.com/FuriousFourier/freeciv/commit/766e48ced7cd9b0c03585cc6c423b206a39b7852. I
generated maps with the same mapseed and gameseed before and after the
patches and compared the saved games. On a 2,000,000 tile map (and on
a smaller map up to 20,000) the map sections (terrain, extras, altitude,
start positions) are identical. The patch doesn't change the order of
random number calls: pick_terrain_by_flag() still gets river tiles in
ascending tile index order.


Files

fasten_map_gen.patch (9.95 KB) fasten_map_gen.patch Paweł Nowak, 11/23/2026 05:09 PM
0001-Fasten-map-generation-v2.patch (10.7 KB) 0001-Fasten-map-generation-v2.patch Paweł Nowak, 11/27/2026 10:39 PM
Actions

Also available in: Atom PDF