LuaJit OOM - how to detect Mods using it - and rid off !

LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Wed Jan 16, 2019 11:57 am

So, I put 32 GB of RAM into the MTS Server (hardware), but usedless as this lua memory we stuck here, is an own area limited to 2GB at Lua and 1 GB at LuaJIT - whatever we have build in. - So to the topic:

How to detect LUAJIT using MODS causing OOM ?
OOM happen, when the amount of luamem is finished = mean bad luck when seen guilty to be the one make the crash
* detect mod using memory --> see LuaJIT here or LUA here
* detect mod with a lot of consumption and get better code or ban mod

or how to reduce LUAJIT amount ?
* mod [stop_lj_oom] tested, but adds lag about 0.8 at my server
and need to be adjusted to an amount to carbagecollect before OOM limit

or try to change availiable lua memory
* there are some ideas, to get LuaJet 2 GB or even 4 GB
but that does not free the programmer from making good slim code, using less memory !

result until 23.03.2019
--> best option to get used lua memory by change a code in

line 45 ... unified_inventory/api.lua - as this is last action could detect yet
Code: Select all
print("Unified Inventory. inventory size: "..unified_inventory.items_list_size

new code, show used mem, make garbagecollect, and show used mem again
Code: Select all
   print("Unified Inventory. inventory size: "..unified_inventory.items_list_size.." / luamem: "..math.floor(collectgarbage("count")).." KB")
      collectgarbage("step",3)
      print(math.floor(collectgarbage("count")).." KB after collectgarbage")

So give it a try, and please report your server: name, Lua or LuaJIT and used lua memory - maybe you and we all then understand OOM much better and can avoid it !

To check out weather I need them or not - to get less OOM and longer runs of the MTS.
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

OOM - older links, this is not new, but not solved also !

Postby Festus1965 » Thu Jan 17, 2019 1:06 am

The OOM is not a fresh case, but I want to get rid of !

Links from further Posts about OOM:
* Lua OOM crashes
* Minetest memory error(Lua OOM error not enough memory)
* Minetest with LuaJit GC64 mode (>2gb mem)
* Lua OOM errors
* Remove LuaJIT support?

* [mod] Stop LUAJIT OOM crashes [stop_lj_oom]

edit: detected now, mods which mods coused crash, (when garbage collector is running)
* mod 'mcl_dungeons'
* mod worldview
* mod technic_worldgen
** here a possible solution - I just edited my mod "memory optimisation fix is simple"
* mod pipeworks
* mod 'biome_lib'
* mod fire
* mod 'televator'
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

biggest [Mod]s LUA memory users yet

Postby Festus1965 » Fri Jan 18, 2019 11:16 pm

so biggest [Mod]s LUA memory users yet:
(from my server "Thailand Minetest.one" under Lua, Map +22 GB)

*11xxx - moreblocks ...
* 9600 - moretrees
* 8200 - technic / technic
* 6350 - technic / chests
* 3350 - pipeworks
* 2500 - technic / extranodes
* 1750 - farming
* 1580 - travelnet
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

biggest [Mod]s LuaJIT memory users yet - empty world

Postby Festus1965 » Mon Jan 21, 2019 4:10 am

so biggest [Mod]s LuaJIT memory users yet:
(from 2nd server empty world with LuaJIT active, also 8 Thread CPU / 32 GM Ram)

*+ 22000 KB - unified_inventory AFTER loading all items (when print "inventory size" on my server for example)
*~ 10500 KB - moreblocks (d96f110 23.03.2019) (TH=direct deactivated)

*~ 5300 KB - technic (700faca 09.03.2019) all, but need also basic_materials, pipeworks
*~ 5250 KB - technic_aluminium (1bddcc7 25.06.2016) all, but need also basic_materials, technic+, pipeworks
*~ 3600 KB - mesecons (073c92d 16.03.2019) all, just NOT commandblock
*~ 3350 KB - homedecor (ac71c0f1 12.2018), all, need unifieddeys (TH=not)
*~ 2900 KB - xdecor (ee7a281 10.03.2019) (TH=12.400 KB)
*~ 2800 KB - unifieddeys (f59c8aff 23.02.2019) (TH=not)
*~ 2550 KB - etherreal (7a1a8728b0 23.03.2019) (TH=deactivated)
*~ 2500 KB - Mobs_redo 1.40 (a1d4e9bbfc 23.03.2019) +_monster +_animals +resources/materials +cooking (TH=+960)
*~ 2100 KB - Mobs_animals (43a813d4f1 22.03.2019), with bat, bird, butterfly, fish, turtle, +Mobs_Redo, +~ 500 KB (TH=+370)
*~ 2000 KB - Unified_Inventory (850ee9c 17.02.2019), but loosing a lot until next loaded mod, like only 1.350 KB used (*!)
*~ 1950 KB - inventorybags (818231c 01.01.2018) (TH=370)
*~ 1900 KB - 3d_armor (1d22612 06.03.2019) full, wieldview, shields, stand, sfinv together, as _armor, hazmat_suit, ui and ip loaded but unused
*~ 1820 KB - Mobs_monster (6cf5b95fc9 22.02.2019), as need also Mobs_Redo, so itself a plus of 170 KB (TH=+180)
*~ 1800 KB - plantlife (4e32feaa 17.03.2019), all, and deed biome_lib
*~ 1750 KB - 3d_armor (only)
*~ 1650 KB - Flowerpot (6bce72a 03.10.2017)
*~ 1650 KB - Mobs Redo 1.49 (07.03.2019), only
*~ 1520 KB - moreores (5010a14 23.03.2019) (TH~80)
*~ 1510 KB - BakedClay (67d0f2a8d6 07.2018) (TH~300)
*~ 1430 KB - moremesecons (2b2faec 20.08.2018) all, NOT commandblock (incl. need of 4 mesecon mod)
*~ 1390 KB - nether (2d94d74 21.12.2017) (TH~960)
*~ 1320 KB - hud/hunger (071cba5852 07.2018), depends on hud +52 = 1372 KB
*~ 1100 KB - crafting (TH~680)
*~ 1000 KB - moretrees (d521e347 12.2018), as depend on biome_lib +400 = 1400 (TH~1050)

*~ 990 KB - treecapitator
*~ 910 KB - mp-xtraores (815fec1 23.06.2017) (TH~90)
*~ 820 KB - digilines (434010b 20.10.2017) (TH~260)
*~ 800 KB - mesecons 1st only
*~ 800 KB - Protector (a2e803d522 10.2018) (TH~200)
*~ 750 KB - signs_lib (c199a33b 12.2018) (TH~200)
*~ 710 KB - more_chests (c597779 27.02.2017)
*~ 710 KB - bitchange (98a2dc8 03.01.2019) (TH~115)
*~ 700 KB - Basic_Materials (a5fdb721 12.2018) (TH~90)
*~ 700 KB - mining_plus (c2d63df 27.08.2016) (TH~100)
*~ 680 KB - smartshop (TH~50)
*~ 680 KB - exchange (TH=off)
*~ 680 KB - mail
*~ 655 KB - servercleaner
*~ 650 KB - localisation (TH=off)
*~ 650 KB - arrow_signs
*~ 650 KB - trash_can (TH=off)
*~ 650 KB - locks
*~ 650 KB - Ballon
*~ 640 KB - jail (13.12.2013)
*~ 630 KB - digtron (d41190a 16.03.2019) old version 1310 KB - (TH~800)
*~ 640 KB - Enchanting (TH=off)
*~ 640 KB - alphabeth
*~ 630 KB - border
*~ 610 KB - soccer (TH=off)
*~ 550 KB - torches
*~ 400 KB - nixie-tubes (6bd1ad70 12.2018), but depend on digilines +820 = 1220 KB (TH~340)
*~ 398 KB - biome_lib (29899f2d 01.2019) (TH~70)
*~ 220 KB - wiki (TH~220)
*~ 175 KB - bows (465b065eb7 12.2018)
*~ 150 KB - areas (TH~500)
*~ 130 KB - WorldEdit (f242f2f 09.12.2018) + commands not more mem (TH=~330)
*~ 125 KB - craftguide (0271f61 21.03.2019)
*~ 125 KB - adv_spawning v0.0.13 (28.12.2015) 0.4.x
*~ 125 KB - economy
*~ 120 KB - travelnet (TH~1000)
*~ 110 KB - euban
*~ 100 KB - farming 1.40 (ee993f9d61 22.03.2019) (TH~1200)

* 80 KB - markers, as depends on areas +150 = 230 KB
* 70 KB - U_Skins, depends on Unified_Inventory +1350 = 1.420 KB
* 52 KB - hud
* 50 KB - Pipeworks (27eb2ca9 01.2019), as depends on basic_material +700 = 750 KB (TH=~2.150)
* 40 KB - minetest_remover
* 40 KB - digiline_remote, but depend on digilines +820 = sum 860 KB
* 35 KB - lamps
* 34 KB - filter
* 24 KB - basic_robot (TH~540)
* 21 KB - player_notes
* 20 KB - nonew
* 15 KB - sightview
* 14 KB - no-guests
* 14 KB - lagcheck

* 9 KB - adblock
* 3 KB - time

* careful:
** unified_inventory is loading all Items after server ready loading mods, at my one near 18.000-22.000 KB memory using plus ! - this can be seen in code change for /unified_inventory/api.lua ... 1st post
at my server another +18.000 KB used then, on the empty world testing, nothing more - as it is only lonely mod

so not false the unified_inventory [Mod] will solve the problem if needed, need to find out what other [Mod] make it load so much !!!

(TH~) mean, the usage on my running server with big world, BUT not trust numbers, as loaded between and never sure how it counts, my LuaJit memory sum is about 49.894 KB after unified_inventory + collectgarbage loaded items.
So short list main memory users on my running TH (Thailand Minetest.one) Server with memory sum ~46.000 KB after deactivated (false) some not important or used [Mod]s

* 22000 KB - unified_inventory AFTER loading all items (print after did "inventory size" )
* 12400 KB - xdecor (ee7a281 10.03.2019)
*~ 2150 KB - Pipeworks (27eb2ca9 01.2019), as depends on basic_material +700 ...
*~ 1200 KB - farming 1.40 (ee993f9d61 22.03.2019)
*~ 1050 KB - moretrees (d521e347 12.2018), as depend on biome_lib +400 = ...
* ~ 960 KB - nether (2d94d74 21.12.2017)
* ~ 800 KB - digtron (d41190a 16.03.2019)
* ~ 500 KB - areas
listed mean already 90% of all lua memory, so the only way to make sure what mod false will reduce memory usage is to print memory usage after unified size and then test with mods = false in .mt

as [Mod]s sure have some kind of combining effects, mean each of them single much memory usage, but together they seam to share or combine some data, = together less memory usage than both single memory usages added

and final about OOM:
* under Lua my crashed between 1133 until 1340 MB
* under LuaJit my crashed between 536 - 846 MB
as some server OOM with just 14 MB would already be gone, my one now starts with 47 MB - so there is a lot of time until 536 MB, better than before when my server started with near 80 MB lua memory

and not forget, why OOM:
so as know now how much lua mem is used at beginning, DURING the game running and used several [Mod]s wanna and take more memory, so this [Mod] then traitor itself with the OOM message,
and so far most of this messages at me was technic !!!
Even technic start smart, seams to do crazy much and often grab more memory

- ... and here I am not able to analyze yet - we need some tool able to show memory usage by [Mod] during gameplay on demand or every hour saved, for testing ...
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Sun Jan 27, 2019 4:50 am

here the changed I did at technic/technic_worldgen/

Code: Select all
-- Sulfur
--local sulfur_buf = {}  -- this is old
local data = {}  --  this is new plus
local sulfur_noise = nil

minetest.register_on_generated(function(minp, maxp, seed)
   local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
   local a = VoxelArea:new{
      MinEdge = {x = emin.x, y = emin.y, z = emin.z},
      MaxEdge = {x = emax.x, y = emax.y, z = emax.z},
   }
   --local data = vm:get_data(sulfur_buf) -- this isold
   vm:get_data(data) -- this is new
   local pr = PseudoRandom(17 * minp.x + 42 * minp.y + 101 * minp.z)
   sulfur_noise = sulfur_noise or minetest.get_perlin(9876, 3, 0.5, 100)


one more,
i am on to learn how to detect the code in the mod and solute it ...

2019-01-27 11:30:47: ERROR[Main]: ServerError: AsyncErr: environment_Step: OOM error from mod 'biome_lib' in callback environment_Step(): not enough memory
2019-01-27 11:30:47: ERROR[Main]: Current Lua memory usage: 1057 MB
2019-01-27 11:30:47: ERROR[Main]: stack traceback:
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Tue Jan 29, 2019 11:21 pm

Code: Select all
2019-01-30 01:53:27: ERROR[Main]: ServerError: AsyncErr: environment_Step: OOM error from mod '[b]fire[/b]' in callback environment_Step(): not enough memory
2019-01-30 01:53:27: ERROR[Main]: Current Lua memory usage: 1274 MB
2019-01-30 01:53:27: ERROR[Main]: stack traceback:
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Tue Feb 05, 2019 10:30 pm

Code: Select all
2019-02-04 17:20:59: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: OOM error from mod 'pipeworks' in callback LuaABM::trigger(): not enough memory
2019-02-04 17:20:59: ERROR[Main]: Current Lua memory usage: 1341 MB
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Tue Feb 05, 2019 10:30 pm

Code: Select all
2019-02-05 14:26:38: ERROR[Main]: ServerError: AsyncErr: environment_Step: OOM error from mod 'televator' in callback environment_Step(): not enough memory
2019-02-05 14:26:38: ERROR[Main]: Current Lua memory usage: 1133 MB
2019-02-05 14:26:38: ERROR[Main]: stack traceback:
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Wed Mar 06, 2019 11:13 am

Maybe I found something,

lua mem profiler

I will check it out next server starts.
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Pyrollo » Wed Mar 06, 2019 3:59 pm

Hi,

I'm very interested to know if it's always because of use of vm get_data (I'm working on performances on big map updates and it may solve some OOM problems).

Do you get some cases when PerlinNoiseMap:get3dMap is implied ?
Pyrollo
Member
 
Posts: 259
Joined: Mon Jan 08, 2018 3:14 pm
GitHub: pyrollo
In-game: Naj

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Thu Mar 07, 2019 1:08 am

Pyrollo wrote:I'm very interested to know if it's always because of use of vm get_data (I'm working on performances on big map updates and it may solve some OOM problems).

Do you get some cases when PerlinNoiseMap:get3dMap is implied ?


OOM
I was checking the git from my seen most OOM causing Mods (technic, pipeworks and mesecons) but cant really see if those are fixed with that code, I asked today morning, but downloaded and test when time

lua mem profiler, (was not running yet)
Code: Select all
2019-03-07 09:01:50: ERROR[Main]: ModError: Failed to load and run script from /home/thomas/.minetest/mods/luaprofiler/init.lua:
2019-03-07 09:01:50: ERROR[Main]: /home/thomas/.minetest/mods/luaprofiler/init.lua:458: '<eof>' expected near 'end'

that is added as mod and loaded without problem, but now I am missing a possibilities to start it
I need to build in some
Code: Select all
minetest.register_chatcommand("luamemcheck", {

what calls then the function
Code: Select all
ProFi:start( 'once' )

will see how to do

PerlinNoiseMap:get3dMap
what is this, where, ... never seen/read this
edit: sorry - this optimization tip is so old, that I couldnt believe or remember it: got it
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Pyrollo » Thu Mar 07, 2019 12:19 pm

Festus1965 wrote:PerlinNoiseMap:get3dMap
what is this, where, ... never seen/read this


I refer to this because I suspect large table transfer from C to LUA to be slow. And it seems also related to OOM you mentioned. One of the solution is to stop creating big table in LUA and use another way to access large collection data from C.
Pyrollo
Member
 
Posts: 259
Joined: Mon Jan 08, 2018 3:14 pm
GitHub: pyrollo
In-game: Naj

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Thu Mar 07, 2019 1:09 pm

yeah, I got it: Mapgen_memory_optimisations - Perlin noise objects So far I got it now is this problem moire new than old, or it is not the reason ...

sure, but that fore i supposed to try some software that tells us, what mod is using most of the memory until it OOM-crashes - and then go to this 2 or 4 mods and optimize like you supposed ...
otherwise we have to upgrade all of them, guessing that is a problem

So analysing first, than act ... ?
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Tue Mar 12, 2019 7:08 am

Pyrollo wrote:I refer to this because I suspect large table transfer from C to LUA to be slow. And it seems also related to OOM you mentioned. One of the solution is to stop creating big table in LUA and use another way to access large collection data from C.


I am so sorry Pyrollo,
but both posts are from
* Sun May 17, 2015 16:16 - Lua PerlinNoiseMap memory efficiency improvements
* Wed May 11, 2016 20:26 - Perlin noise exceeds -1/1 range

so that I was quite sure that should have been solved ...

and so I am more locking in this direction Important oregen memory use optimization from Dec 2018 to understand ... I read a lot last 5 days, and will try out if have fun to do ...

as after that 5 days there was another 11 crashes, 7 of them by technic OOM hehe

I am looking for some tricks told
* https://stackoverflow.com/questions/27015150/how-to-get-past-1gb-memory-limit-of-64-bit-luajit-on-linux
* https://kvitajakub.github.io/2016/03/08/luajit-memory-limitations/
* https://github.com/cloudflare/luajit-mm
but still need to get back another (is in Celine's PC but she play Roblox - so I cant ...)
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Sat Mar 16, 2019 1:43 am

I had at last now only one solution,
I don't use LuaJit anymore as the speed plus is not seen on my server.

Instead of 8-10 hours with LuaJit, it is running now more than 14 hours,
and there are more important issues I have to work on = my daughter, and as she didn't play anymore minetest ... I am done here. The automatic restart is so fast, and refresh also server ... I accept crashes now as even see how fast boomed gamer join in after.
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Mon Mar 18, 2019 3:21 am

maybe got closer,
as I added the command printgarbagecolect(count) after each loading [Mod] I got the sum after most of the prepared mod now, and the difference from before count and after got a list:

Code: Select all
so biggest user yet sure:
* 9600 - moretrees
* 8200 - technic / technic
* 6350 - technic / chests
* 3350 - pipeworks
* 2500 - technic / extranodes
* 1750 - farming
* 1580 - travelnet
still missing some 5 have to define more often, as still 2-5 [Mod] share a amount as not print sum between
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Tue Mar 19, 2019 1:21 pm

So first,
* LuaJit is limited to some count of ram, 1 GB ... (64bit, linux or so like and lua has 2 GB)
* next it seams to depend on other issues like release also, as I have seen OOM at 64 MB, my one before was 1350 MB, and now I am back to crash at 850 MB (rode that it depends on the starting position of this ram using for get near 1 GB)

and now I may have found out the ram consumption of Mod running at me, so we come closer

it works with adding this code at and of every [Mod], ...
Code: Select all
luamemnew = collectgarbage("count")
print("[Mod] time *(version/date) - loaded - with "..math.floor(luamemnew - luamemold).." more Lua Mem used")
luamemold = luamemnew

so first check the code that sure what I was measure there ...

and that is what i get print out at server start (screen): is here
sure still some not even edited ...
but so far a (part deleted as mod load before first count-printout)

* deleted as misleading *

but VanessaE wrote ...
* moretrees:
Wrong repository, and Moretrees doesn't allocate any memory of consequence.

* pipeworks:
Wrong repository, and Pipeworks doesn't allocate any memory of consequence.

mhh, what is OOM telling, and garbagecollect writing, I am getting confused ,
but at
* technic, she didn't answer that or any ... so some hope.

But: I remember no any program can run without using mem, mhhh

So another task tomorrow might be to ask those server-admins also with OOM errors, what of this maybe heavy loading mods they had also installed, mean also much more closed to OOM than other servers without this. Top-[Mod]s ... As not all had this issue, and so maybe found a reason

next change
* wanna see sum at the last loading, to get % of one mods usage to sum,
* wanna try one garbagecollect at end of last loaded mod, with again show used sum
at me in hazmat_suit loaded last i can see
Code: Select all
-- and as lastloaded sum and some clean
print(collectgarbage("count"))
collectgarbage(step,3)
print(collectgarbage("count"))
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Wed Mar 20, 2019 4:40 am

basic new first: last loading [Mod] gives more out now as print.count, garbagecollect, print.count =
Code: Select all
72930.500976562
.. garbagecollecting ...
62376.912109375

so just use garbagecollect() at last on last loading [Mod] saves me here 72930 - 62376 = 10.554 Kbytes or 10 MB
Result: just to save mem, make sure the last lua is garbagecollect() in the last [Mod] loading as here saving 14% memory.

And also: when count all results single together I get a sum of 73237 KB, so
as at start 599 KB used
+ plus 73237 KB sure in reporting [Mod]s (missing yet the build in minetest_game)
mean then should be 73836
but as last reported 72930,
mean also some 906 KB released itself during the start.

and check as I edited more [Mod]s with the calculation code, will take with >=1000 KB
Code: Select all
* 11960 - 16.3% - moreblocks (9363068 09.03.2019) - (+24)
* 9592 - 13.1% - Moretrees (d521e347 01.2019) - (+1)
* 8215 - 11.2% - technic / technic (700faca 10.04.2019)
* 6928 - 9.5% - Ethereal (9bbd90e0b4 01.03.2019)
* 6189 - 8.5% - BakedClay (67d0f2a8d6 02.07.2018)
* 3363 - 5.6% - Pipeworks (27eb2ca9 01.2019) (+1)
* 3287 - 4.5% - farming redo 1.40 (13.02.2019)
* 2546 - 3.5% - technic / _extranodes (700faca 10.04.2019)
* 1362 - technic / _worldgen (700faca 10.04.2019)
* 1318 - travelnet (+3)
* 1151 - xdecor (ee7a281 10.03.2019) - (-23)
* 1043 - biome_lib - (+21)
* 1021 - digtron (14.01.2019)
* 948 - crafting
* 975 - animalmaterials / animalmaterials
* 914 - basic_robot


add:
* the also loaded [Mod]s out of game are also edited with the report code next start.
* issues about lua memory usage are done into the 3 top named
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Thu Mar 21, 2019 12:54 am

as a result of yesterday, even change every mod init.lua again, so that the totalmem is measured to beginn, and at the end of the loading time of a mod, and show difference, seams to be a problem, as sometime less using, mean result -30 KB.

so seam to be better to just false a [Mod] in minetest.mt, restart server and check mem, then this confusing even - x KB might be gone

remember LuaMem is limited by Lua itself so 2 GB on x64 linux mashines, and as of "bad" configuration, not starting at bottom, and reach limit of the 2 GB window sometime much faster, mean OOM from 14 MB up to me at 1300 MB!
and for LuaJit the max is 1GB,so speed against space ...

this is my running system, with a lot together loaded mods and there usage by calculating minus from normal memory usage.
etherreal on, 19.418 LuaMem used, to base 17.383 KB with etherreal off
moreblocks on, 37.290 LuaMem used, ...
xdecor off, only 17.383 KB LuaMem used, mean 23.259 - 17383 = real 5.876 KB used from xdecor ...

so more safe results under LuaJit ? -
Code: Select all
* 9.531 KB - moreblocks
* 5.876 KB - xdecor
* 2.035 KB - etherreal


loading now only ONE mod plus same time, then off, next mod on, so this list is single mod loading, just also minetest_game is with base used memory shown 373
add: 21.03. - just preparing a copy of server, and then world.mt just on/off mods and see the memory usage (still LuaJIT On) -
Code: Select all
*  879 KB - xdecor (startmem here 2324 KB, even only alone)
*   55 KB - travelnet, startmem 430 KB
*   12 KB - towercrane, but startmem before here 1008-1033
*    3 KB - time

so, here again, total NOT logic - I thought the used starting memory should be same when only one mod starts, but it isn't ... so one smal mod load before and then different 2md one ... check with time , as tested more often, 373 KB at start, using 3 KB
so the starting mem 373 and using time keeps stable with 373 + 3 KB, and
Code: Select all
* 2330 - xdecor (10 time starting, one out of that at 1750 KB )
* 2210 - etherreal (10 starts very closed result)
* 1076 - biome_lib (10 starts but allocating mem before first print luamam count, see code down)
*    3 - time (will be in all time then)


examples: biome_lib
biome_lib:
Code: Select all
Mem time Start with: 373
[Mod] time *(version/date) - loaded - with 3 KB
Mem time End with: 377
Mem biome_lib Start with: 1066
[Mod] biome_lib (11.05.2018) - loaded - with 6 KB
Mem biome_lib End with: 1073


and once again, cant trust even this start end of mod take count and compare, as it loads already before it counts, so at the end, just can take end count show, and have to take the diff to start/end time - myself ... oh oh

like this at last line of the init.lua
Code: Select all
print("[Mod] name (date) ver - loaded - end with "..math.floor(collectgarbage("count")).." KB")

works, and gives a good point
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

LuaJit OOM - mem using of mods in Lua and LuaJit ranking

Postby Festus1965 » Thu Mar 21, 2019 10:34 am

ShadowNinja commented on Mar 13, 2016
@twoelk: There's nothing to do but minimize memory usage, which mods should be doing already anyway.

and there is still a coder (have even been posting in that theme), believe that build in RAM (like at me 32 GB) will solve the problem, not understand that the lua uses own prepared 2 GB, LuaJIT 1GB inside this RAM, what is a fixed coded problem, not a hardware issue.

But anywhere if LUA 2 GB, or LuaJIT 1 GB ... ban too much luamem using mods, so they will act ...

so this seams to work, similar to my first counting with Lua up, just show end luamem, and diff by hand
Lua: on my running system
Code: Select all
*11936 - moreblocks (deactivated)
* 9600 - moretrees
* 8200 - technic / technic
* 6350 - technic / chests
* 3350 - pipeworks
* 2500 - technic / extranodes
* 1750 - farming
* 1580 - travelnet
as compare mem usage under Lua only

used
Code: Select all
print("[Mod] [modpack /] name (date) version - loaded - end with "..math.floor(collectgarbage("count")).." KB")
at the end of mod.init.lua
just show count end mem sum, with just fixed one mod time starting before, ending up at 377 KB
LuaJIT loaded on an empty world ...
Code: Select all
*~10500 KB - moreblocks (direct deactivated on my server)
*~ 3600 KB - mesecons all, just NOT commandblock
*~ 2900 KB - xdecor
*~ 2550 KB - etherreal (new, but also deactivated on my server)
*~ 2000 KB - Unified_Inventory, but loosing a lot until next loaded mod, like only 1.350 KB used
          ! loading all Items after server ready, at my one near 18.000 KB plus !
*~ 1950 KB - inventorybags
*~ 1750 KB - 3d_armor
*~ 1650 KB - Flowerpot
*~ 1520 KB - moreores
*~ 1510 KB - BakedClay
*~ 1390 KB - nether
*~ 1320 KB - hud/hunger, depends on hud +52 = 1372 KB
*~ 1310 KB - digtron
*~ 1100 KB - crafting
*~ 1000 KB - moretrees, as depend on biome_lib +400 = 1400
*~  990 KB - treecapitator
*~  910 KB - xtraores
*~  850 KB - signs_lib
*~  820 KB - digilines
*~  800 KB - mesecons 1st only
*~  800 KB - Protector
*~  710 KB - more_chests
*~  710 KB - bitchange
*   700 KB - Basic_Materials
*   700 KB - mining_plus
*~  680 KB - smartshop
*~  680 KB - exchange
*~  680 KB - mail
*~  655 KB - servercleaner
*~  650 KB - localisation
*~  650 KB - arrow_signs
*~  650 KB - trash_can
*~  650 KB - locks
*~  650 KB - Ballon
*~  640 KB - Enchanting
*~  640 KB - alphabeth
*~  630 KB - border
*~  610 KB - soccer
*   550 KB - torches
*   400 KB - nixie-tubes, but depend on digilines +820 = 1220 KB
*   398 KB - biome_lib
*~  175 KB - bows
*   150 KB - areas
*   125 KB - craftguide
*   125 KB - economy
*~  120 KB - travelnet
*~  110 KB - euban
*    80 KB - markers, as depends on areas +150 = 230 KB
*    70 KB - U_Skins, depends on Unified_Inventory +1350 = 1.420 KB
*    52 KB - hud
*    50 KB - Pipeworks, as depends on basic_material +700 = 750 KB
*    40 KB - minetest_remover
*    35 KB - lamps
*    34 KB - filter
*    21 KB - player_notes
*    20 KB - nonew
*    15 KB - sightview
*    14 KB - no-guests
*    14 KB - lagcheck
*     9 KB - adblock
*     3 KB - time
as have seen at Unified_Inventory, it seams to depend on also the other installed [Mod] how much memory one [Mod] itself will use, see Unified_Inventory

mesecons each as start: all ~ 3.600 KB without commandblock
Code: Select all
Mem time Start with: 370
[Mod] time *(version/date) - loaded - sum: 374 KB
[Mod] mesecons / mesecons (30.12.2018) 0.4.x - loaded - end with 1152 KB
[Mod] mesecons / wires (30.12.2018) 0.4.x - loaded - end with 2073 KB
[Mod] mesecons / torch (30.12.2018) 0.4.x - loaded - end with 2089 KB
[Mod] mesecons / switch (30.12.2018) 0.4.x - loaded - end with 2098 KB
[Mod] mesecons / receiver (30.12.2018) 0.4.x - loaded - end with 2161 KB
[Mod] mesecons / wallever (30.12.2018) 0.4.x - loaded - end with 2175 KB
[Mod] mesecons / button (30.12.2018) 0.4.x - loaded - end with 2190 KB
[Mod] mesecons / random (30.12.2018) 0.4.x - loaded - end with 2203 KB
[Mod] mesecons / pressureplates (30.12.2018) 0.4.x - loaded - end with 2269 KB
[Mod] mesecons / powerplant (30.12.2018) 0.4.x - loaded - end with 2275 KB
[Mod] mesecons / noteblock (30.12.2018) 0.4.x - loaded - end with 2286 KB
[Mod] mesecons / mvps (30.12.2018) 0.4.x - loaded - end with 2306 KB
[Mod] mesecons / stickyblocks (30.12.2018) 0.4.x - loaded - end with 2310 KB
[Mod] mesecons / pistons (30.12.2018) 0.4.x - loaded - end with 2368 KB
[Mod] mesecons / microcontroller (30.12.2018) 0.4.x - loaded - end with 2482 KB
[Mod] mesecons / materials (30.12.2018) 0.4.x - loaded - end with 2487 KB
[Mod] mesecons / solarpanel (30.12.2018) 0.4.x - loaded - end with 2504 KB
[Mod] mesecons / movestones (30.12.2018) 0.4.x - loaded - end with 2528 KB
[Mod] mesecons / detector (30.12.2018) 0.4.x - loaded - end with 2545 KB
[Mod] mesecons / luacontroller (30.12.2018) 0.4.x - loaded - end with 2039 KB
[Mod] mesecons / lamp (30.12.2018) 0.4.x - loaded - end with 2052 KB
[Mod] mesecons / insulated (30.12.2018) 0.4.x - loaded - end with 2067 KB
[Mod] mesecons / hydroturbine (30.12.2018) 0.4.x - loaded - end with 2084 KB
[Mod] mesecons / fpga (30.12.2018) 0.4.x - loaded - end with 2211 KB
[Mod] mesecons / extrawires (30.12.2018) 0.4.x - loaded - end with 2304 KB
[Mod] mesecons / delayer (30.12.2018) 0.4.x - loaded - end with 2346 KB
[Mod] mesecons / gates (30.12.2018) 0.4.x - loaded - end with 2419 KB
[Mod] mesecons / blinkyplant (30.12.2018) 0.4.x - loaded - end with 2432 KB
[Mod] mesecons / alias (30.12.2018) 0.4.x - loaded - end with 2443 KB
[Mod] mesecons / doors (30.12.2018) 0.4.x - loaded - end with 3642 KB
[Mod] mesecons / lightstone (30.12.2018) 0.4.x - loaded - end with 3901 KB (until 3962, tested 10 times)
2019-03-21 18:25:37: ACTION[Server]:


and with moremesecons, incl. needed 4 part out of mesecons to start
Code: Select all
[Mod] time *(version/date) - loaded - sum: 374 KB
[Mod] MoreMesecons / utils (2b2faec on 20.08.2018) 0.4.x - loaded - with 381 KB
[Mod] mesecons / mesecons (30.12.2018) 0.4.x - loaded - end with 1150 KB
[Mod] MoreMesecons / wireless (2b2faec on 20.08.2018) 0.4.x - loaded - with 1220 KB
[Mod] MoreMesecons / timegate (2b2faec on 20.08.2018) 0.4.x - loaded - with 1243 KB
[Mod] MoreMesecons / teleporter (2b2faec on 20.08.2018) 0.4.x - loaded - with 1257 KB
[Mod] MoreMesecons / teleporter (2b2faec on 20.08.2018) 0.4.x - loaded - with 1273 KB
[Mod] MoreMesecons / signalchanger (2b2faec on 20.08.2018) 0.4.x - loaded - with 1289 KB
[Mod] MoreMesecons / mesechest (2b2faec on 20.08.2018) 0.4.x - loaded - with 1331 KB
[Mod] MoreMesecons / luacontroller (2b2faec on 20.08.2018) 0.4.x - loaded - with 1354 KB
[Mod] MoreMesecons / luablock (2b2faec on 20.08.2018) 0.4.x - loaded - with 1401 KB
[Mod] MoreMesecons / jammer (2b2faec on 20.08.2018) 0.4.x - loaded - with 1419 KB
[Mod] MoreMesecons / injectorcontroller (2b2faec on 20.08.2018) 0.4.x - loaded - with 1436 KB
[Mod] MoreMesecons / detector (2b2faec on 20.08.2018) 0.4.x - loaded - with 1454 KB
[Mod] MoreMesecons / dualdelayer (2b2faec on 20.08.2018) 0.4.x - loaded - with 1472 KB
[Mod] MoreMesecons / conductor_signalchanger (2b2faec on 20.08.2018) 0.4.x - loaded - with 1488 KB
[Mod] MoreMesecons / commandblock (2b2faec on 20.08.2018) 0.4.x - loaded - with 1510 KB
[Mod] MoreMesecons / adjustable_player_detector (2b2faec on 20.08.2018) 0.4.x - loaded - with 1528 KB
[Mod] MoreMesecons / adjustable_blinkyplant (2b2faec on 20.08.2018) 0.4.x - loaded - with 1543 KB
[Mod] mesecons / torch (30.12.2018) 0.4.x - loaded - end with 1559 KB
[Mod] MoreMesecons / transmitter (2b2faec on 20.08.2018) 0.4.x - loaded - with 1578 KB
[Mod] mesecons / noteblock (30.12.2018) 0.4.x - loaded - end with 1588 KB
2019-03-23 12:45:34: WARNING[Main]: [moremesecons_sayer] use_speech_dispatcher = true, but the speech dispatcher can only be used in singleplayer
[Mod] MoreMesecons / _sayer (2b2faec on 20.08.2018) 0.4.x - loaded - with 1618 KB
[Mod] mesecons / materials (30.12.2018) 0.4.x - loaded - end with 1624 KB
[Mod] MoreMesecons / playerkiller (2b2faec on 20.08.2018) 0.4.x - loaded - with 1634 KB
[Mod] MoreMesecons / ignitter (2b2faec on 20.08.2018) 0.4.x - loaded - with 1803 KB


60 [Mod]s done yet, another 120+ waiting, arghhh
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Sat Mar 23, 2019 4:39 am

result until 23.03.2019
--> best option to get used lua memory by change a code in

line 45 ... unified_inventory/api.lua - as this is last action could detect yet
Code: Select all
print("Unified Inventory. inventory size: "..unified_inventory.items_list_size

new code, show used mem, make garbagecollect, and show used mem again
Code: Select all
   print("Unified Inventory. inventory size: "..unified_inventory.items_list_size.." / luamem: "..math.floor(collectgarbage("count")).." KB")
      collectgarbage("step",3)
      print(math.floor(collectgarbage("count")).." KB after collectgarbage")

So give it a try, and please report your server: name, Lua or LuaJITand used lue memory
To check out weather I need them or not - to get less failure and longer runs of the MTS.

I will see when I can continue the mod memory consumption on the 2nd machine,
or if you really want to know about one I didn't test, post it with the link to source
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Sat Mar 23, 2019 9:27 am

So far I am ready with check all [Mod]s i use for lua memory size, or think about to use
A long list with the [Mod]s and there lonely lua memory usage under LuaJIT is here

I will then add some measurements from my running server, as it is for unified_inventory, which is a big difference on empty world or at me.

So if you mean to need another mod, especial when you had OOM before, post the Mod, best we measure on the newest version getting on git..., and we put in here also

but as I have seen, an empty load is not real to compare with the load on running server,
so when you got OOM, might be the best to
* add print at and of all init.lua code show men status,
* change also unified_inventory to get most last sum of lua memory used
and then test on DB copy, or sure without any login !!!, to false some thought big one, and see the final memory usage. If there is a big difference to before, you got a number saving memory for false this mod.

Might me much work,
but be sure my server is much faster now, as less heavy mods, and less using memory, might keep OOM far away.
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Sun Mar 24, 2019 6:01 am

as I saw today some [Mod]s have newer change dates I download and test them on 2nd system again, without any other [Mod] and an empty same world about lua memory consumption:
* unified_inventory - no change
* moreores - no change
* hud_hunger - no change
* bitchange - no change
* digtron - 630 instead of 1330 KB

would be nice for me to understand how to change for less using and also faster working.

often I see at start declarations without local ...
moreores/init.lua
Code: Select all
moreores = {}

local modpath = minetest.get_modpath("moreores")

local S, NS = dofile(modpath .. "/intllib.lua")
moreores.S = S
moreores.NS = NS
...
and sometime I jsut try one on the 2nd server, but like here, as more .lua files are included it is more difficult ...

unified_inventory ... with a lot could be local ?
Code: Select all
-- Unified Inventory for Minetest >= 0.4.16

local modpath = minetest.get_modpath(minetest.get_current_modname())
local worldpath = minetest.get_worldpath()

-- Intllib
local S, NS = dofile(modpath .. "/intllib.lua")

-- Data tables definitions
unified_inventory = {
   activefilter = {},
   active_search_direction = {},
   alternate = {},
   current_page = {},
   current_searchbox = {},
   current_index = {},
   current_item = {},
   current_craft_direction = {},
   registered_craft_types = {},
   crafts_for = {usage = {}, recipe = {} },
   players = {},
   items_list_size = 0,
   items_list = {},
   filtered_items_list_size = {},
   filtered_items_list = {},
   pages = {},
   buttons = {},

   -- Homepos stuff
   home_pos = {},
   home_filename =   worldpath.."/unified_inventory_home.home",

   -- Default inventory page
   default = "craft",

   -- intllib
   gettext = S,

   -- "Lite" mode
   lite_mode = minetest.settings:get_bool("unified_inventory_lite"),

   -- Trash enabled
   trash_enabled = (minetest.settings:get_bool("unified_inventory_trash") ~= false),

   pagecols = 8,
   pagerows = 10,
   page_y = 0,
   formspec_y = 1,
   main_button_x = 0,
   main_button_y = 9,
   craft_result_x = 0.3,
   craft_result_y = 0.5,
   form_header_y = 0
}
...


read a bit:
b = nil
After that, it is as if the variable had never been used. In other words, a global variable is existent if (and only if) it has a non-nil value.
good ! - problem, when I know that this global or local var is not used anymore and can set it nil ? (end of lua script)

also from here: https://rubenwardy.com/minetest_modding_book/en/basics/lua.html
“local” variables declared outside of any functions in a script file will be local to that script. A script can return a value, which is useful for sharing private locals:

so often I see [Mod]s with several spitted scripts, but as long those are called from lua.init, a local var defined there is available at the others also. hmm thinking ...

seams not to be,
but so far atom with language_lua package, also luajit and dbg_lua is installed and running
playing also around with git. ...

tested out of xdecor
Code: Select all
xdecor = {}
local modpath = minetest.get_modpath("xdecor")

dofile(modpath.."/handlers/animations.lua")
to change "local xdecor = {}" ... getting
Code: Select all
2019-03-24 17:16:20: ERROR[Main]: ModError: Failed to load and run script from /home/thomas/.minetest/mods/xdecor/init.lua:
2019-03-24 17:16:20: ERROR[Main]: /home/thomas/.minetest/mods/xdecor/handlers/animations.lua:6: attempt to index global 'xdecor' (a nil value)
what mean this change to local is not going with in the dofile call ...

but at [Mod] border i found something interesting, cleaing up after set a var to nil
Code: Select all
local function update_visa_cache(name)
   --if name exists in cache remove it
   if visa[name] then
      visa[name] = nil
      collectgarbage()
   else
      -- cache visa
      visa[name] = os.time() + duration
   end
   mod_data:set_string("visa", minetest.serialize(visa))
end


so this combination
Code: Select all
somevar = nil
collectgarbage()
I like, and when search all [Mod]s I have here a "= nil" is found 1248 times in 263 files, what might be some start to do similar, mainly at the big memory using [Mod]s
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Thu Mar 28, 2019 7:14 am

check and clean up Lua(JIT) memory size during server is active, without change [Mod]s,
* if WorldEdit true
to check size
Code: Select all
//lua print(math.floor(collectgarbage("count")))
or then to clean
Code: Select all
//lua collectgarbage()
with privs server
* if luacmd true
Code: Select all
/lua print(math.floor(collectgarbage("count")))
or then to clean
Code: Select all
/lua collectgarbage()
with privs lua
/lua tested on my 2nd server, with just minimal settings
//lua works fine on main server (showed 72 MB, cleaned to 69 MB)
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer

Re: LuaJit OOM - how to detect Mods using it - and rid off !

Postby Festus1965 » Thu Mar 28, 2019 9:00 pm

news:
* new version of moreblocks have funny issues, during loading show less mem usage, but after all loaded same more, and after final collectgarbage() still 1500 KB more used then before

* I wrote an own [Mod] free_lj_mem what is in testing but free to try
** collectgarbage() every set x (3600, mean 1 hour) with
** yes or no, to report in log / terminal / to player
** set maxluamem (thought about 10% under known OOM mem) with
** yes or no to each report or terminal or send message to player (to set name) as warn of possible OOM !
** also detecting if lua or luajit and version is running (for further ideas)

* during testing on 2nd system realize that
** every player join in, rise the luamem also (need to be confirmed)

Version 1.1 is running on my server and show, I think, good behavior.
Festus1965
Member
 
Posts: 948
Joined: Sun Jan 03, 2016 11:58 am
GitHub: Minetest-One
In-game: Thomas Explorer



Return to Problems



Who is online

Users browsing this forum: Bing Bot [Bot] and 0 guests