ShadMOrdre / lib_mg_continental

Voronoi influenced terrain generation.
GNU Lesser General Public License v2.1
0 stars 1 forks source link

LuaJIT OOM issue #4

Open gaelysam opened 4 years ago

gaelysam commented 4 years ago

I systematically get crashes, with memory saturating after several minutes of calculation. I'm using LuaJIT. Here are the logs:


2020-04-06 19:34:40: [Main]: [MOD] lib_mg_continental:  Version:0.1.0
2020-04-06 19:34:40: [Main]: [MOD] lib_mg_continental:  Legal Info: Copyright 2019 ShadMOrdre, paramat, Termos, burli, Gael-de-Sailly, duane-r, and others
2020-04-06 19:34:40: [Main]: [MOD] lib_mg_continental:  License: LGLv2.1
2020-04-06 19:34:40: WARNING[Main]: WARNING: minetest.setting_* functions are deprecated.  Use methods on the minetest.settings object. (at /home/gael/.minetest/mods/lib_mg_continental/init.lua:32)
2020-04-06 19:34:40: [Main]: [lib_mg_continental_mg_dev_voronoi] Custom Data Load / Gen Start
2020-04-06 19:34:40: [Main]: [lib_mg_continental_voronoi] Random Points generation start
2020-04-06 19:34:40: [Main]: [lib_mg_continental_voronoi] Voronoi Cell Point List:
#Index|Pos.Z|Pos.X
1|367|218
2|80|-315
3|285|-85
4|225|172
5|-304|79
6|72|-133
7|256|-152
8|-6|-17
9|281|12
10|115|-125
11|-231|325
12|25|76
13|-261|-216
14|106|336
15|-278|72
16|56|-342
17|-116|187
18|33|-233
19|177|41
20|-263|17
21|272|-173
22|302|183
23|-26|-32
24|-322|-122
25|-83|-127
26|226|130
27|-202|-286
28|7|-124
29|281|-338
30|55|327
31|-229|167

2020-04-06 19:34:40: [Main]: [lib_mg_continental_voronoi] Random Points generation time 0.00016399999999805 ms
2020-04-06 19:34:40: [Main]: [lib_mg_continental_voronoi] Cell Data (Cells, Neighbors, Midpoints) generation start
2020-04-06 19:34:40: [Main]: [lib_mg_continental_voronoi] Cell Data (Cells, Neighbors, Midpoints) generation time 0.024654000000005 ms
2020-04-06 19:34:40: [Main]: [lib_mg_continental_voronoi] Cell Data save time 0.00023399999999896 ms
2020-04-06 19:34:40: [Main]: [lib_mg_continental_voronoi] Voronoi Data generation time 26 ms
2020-04-06 19:34:40: [Main]: [lib_mg_continental_voronoi] Voronoi and Edges Maps generation start
2020-04-06 19:36:22: [Main]: [lib_mg_continental_voronoi] Voronoi and Edges Maps generation time 99.900932 ms
2020-04-06 19:36:23: [Main]: [lib_mg_continental_voronoi] Voronoi and Edges Maps save time 0.012627000000009 ms
2020-04-06 19:36:23: [Main]: [lib_mg_continental_voronoi] Voronoi and Edges Maps Total generation time 99914 ms
2020-04-06 19:36:48: ERROR[Main]: ModError: Failed to load and run script from /home/gael/.minetest/mods/lib_mg_continental/init.lua:
2020-04-06 19:36:48: ERROR[Main]: not enough memory```
ShadMOrdre commented 4 years ago

It appears that attempting to generate a 1000x1000 voronoi map crashes. It is a heavy process, and the map it creates saves out to a 120-130 MB file, deserialized from MT. I would like to do away with the map altogether, replacing it with a more efficient test to determine distance to the center of the voronoi cell from the generated chunk center.

The generated voronoi map saves the index of the cell, and the distance to the cell center pos. Rather than rely on this memory heavy data struct, I should only test the distance once, during on_gen, and only for the center pos of the generated chunk. The voronoi map is also an issue because it is tied to a scale factor, and so areas outside of -10000 -10000 x 10000 10000 will have issues if not crash.

The current dev branch should provide a less memory intensive alternative, as it doesn't use registered biomes or lib_materials/lib_ecology biomes. I need to update this dev branch code to accurately point to default nodes instead of lib_mat/lib_eco nodes.

ShadMOrdre commented 4 years ago

I updated the dev branch code. Please test that branch.

ShadMOrdre commented 4 years ago

I have updated the code significantly.

Recursive voronoi cells. Also included two data files, so that you don't crash when trying to generate the files.

gaelysam commented 4 years ago

nice! will test this weekend