-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experimental async_controller (luac) #371
Comments
et Huhhila et et should i make an issue at https://github.com/pandorabox-io/in-game/issues for this though it will still require a lot more testing than what i have now i guess i am gonna try making a survival friendly copy paste tool SX et SX et SX et SX et SX et
SX et SX et SX et SX et SX et so when adding minetest.debug(time_took) repeat -- these are really random, it takes hoewer much my computer feels like @sx how much more should the bottom one be punished than the top one, i can only increase the heat of the luacontroller by +1 (so heat can't be like 19.35+math.pi) SX et et et SX iceyou SX SX et et iceyou et SX iceyou et instruction limits do exist in async luac, they are just 10x bigger than in normal luac SX et SX birdlover32767 et @sx soo do i just create the issue and copy over some context frogTheSecond SX et |
i've rewritten it a bit (seperated the init.lua file into smaller files) |
the ratelimiting problem has been solved (hard 10ms [previously 20ms] limit per event) and some of the bad luac bugs are harder to do now and also fixed that |
i feel like the recipe is a little too... cheap because of the computing power
|
Could also make sense to use multiple lua controllers and maybe few ic's for recipe as it will be multi core in the end anyway. Like 3 - 6 luac on bottom row(s), maybe ic or two on top of that and some copper for heat transfer (block if you feel it would be too cheap otherwise). For recipes I think it is good to think what it actually does and try to reflect that on recipe if possible. |
Sorry for not responding, i was kinda distracted with developing a new mod I will change the recipe then, maybe to something like (where luac = luacontroller, copp = copper block and heat = heatsink)
|
I like this recipe a lot more. Another kinda expensive item is digimese. IIRC heatsink is from [digistuff]. Maybe you want an alternative recipe for servers that don't have that mod installed. |
:( i thought that one was good
|
I was about to say, at 16x16 pixels none of the text will be readable. I don't mind a frowny face, but it might be a bit over the top. Just a shade darker red might be sufficient. |
i would love if it was more different from the digistuff component textures (why are they so overused) but i have no idea how to achieve that Also birdlover, why add that text? |
also, should the async_controller include extra stuff in it's environment like a safe version of loadstring and pcall? (The main issue with pcall was that the execution could continue after the hook got wiped) And loadstring with a character limit and proper sandboxing (not allowing bytecode, disabling jit, setfenv, etc.) would most likely be safe and allow for cool things |
there are also a lot of things in the minetest namespace that are safe also idea: maybe there should be a node, that when placed next to the async_controller will allow access to this fancy environment(?) |
that was for... april foolz also here is a list of safe mt stuff
|
oh wow that's a lot of things, i will simplify the list things will update as i go and implement the things from the list Also edit: everything was reworked somewhat, here is how the functions are edited:
"+" - will add fully (maybe still needs to be reworked) - ItemStack (why)
- ItemStackMetaRef (why v2)
- PerlinNoise (Due to async limitations i can't)
- PerlinNoiseMap (same thing)
- minetest.get_modnames
+/ minetest.get_game_info (don't expose path, since some people have their real life name as their username for some reason?)
+ minetest.is_singleplayer
+ minetest.features
~ minetest.has_feature
+ minetest.get_version
+ minetest.sha1
+ minetest.sha256
+ minetest.colorspec_to_colorstring
+ minetest.colorspec_to_bytes
+ minetest.encode_png
+ minetest.urlencode
- minetest.string_to_privs (no)
- minetest.privs_to_string (no)
+ minetest.formspec_escape (could be useful for another project of mine....)
+ minetest.explode_table_event (useful)
+ minetest.explode_textlist_event (useful)
+ minetest.explode_scrollbar_event (useful)
+ minetest.inventorycube
~ minetest.dir_to_facedir
~ minetest.facedir_to_dir
~ minetest.dir_to_fourdir
~ minetest.fourdir_to_dir
~ minetest.dir_to_wallmounted
~ minetest.wallmounted_to_dir
~ minetest.dir_to_yaw
~ minetest.yaw_to_dir
~ minetest.is_colored_paramtype
~ minetest.strip_param2_color
- minetest.player_exists
+ minetest.serialize (i don't know how theese work but i will assume they are just some sort of pcall(table))
+ minetest.deserialize (same thing)
+ minetest.compress
+ minetest.decompress
+ minetest.rgba
+ minetest.encode_base64
+ minetest.decode_base64
- minetest.global_exists outside of minetest: + pcall = safe.pcall
+ xpcall = safe.xpcall
+ loadstring = safe.get_loadstring(env)
+ bit = table.copy(bit)
+ vector = table.copy(vector) |
Some of those would work well as [mooncontroller] libraries. |
ItemStack() could be interesting to more easily inspect an item's meta. Not sure though if it would work well constructing an ItemStack from info given by a lua- or detector-tube. |
You would need to receive an item stack with that meta info right? (or maybe its the item string that contains it?) (If luacontrollers could send something hard to serialize through digilines that would probably cause crash bugs on many digilines devices) Maybe there could be a function to construct a table from an item string but i don't think a full ItemStack is possible because of async limitations |
so i just realised how horrid my code was (i was noob with async and didnt think register_async_dofile was worth the effort) Expect a huge change soon (mostly just to make reading the code easier) |
actually no it would be way too much to basically rewrite this |
also i forgot to mention, minetest.sha256 is going away too as i think thats a 5.9.0 thing(?) |
Is pcall hard requirement in async environment. Like I've no idea but it is possible it might not be... of course not having it would also mean dropping some good features. |
what do you mean by hard requirement and async environment i just thought pcall would be a cool feature and i saw a mesecons pull request that added a safe version of it (the problem with unsafe pcall was that you could evade the "Code Timed Out" errors and the timeout hook would no longer work once that error got caught) also now i am pretty sure that 50ms is caused by all of the safe pcalls error'ing because code timed out and i am pretty sure it's fixable by not allowing you to basically chain pcalls infinitely |
I mean main reason for pcall for luac programs is to not crash whole Lua VM (to bring down minetest server) with luac program error. I was thinking would it be possible to disable all pcalls when code is about to get executed in async env / separate vm. |
The sandbox needs to use pcall for the user code
No minetest would crash if there's an error in the async environment |
also, running 200 async_controllers (yes literally 200) with the code: interrupt(0)
<uhh this code would actually make the normal luacontroller OOM or freeze the server, but async_controller has a proper time limit alongside an instruction limit so it won't happen, i don't want to leak it here, if you want to know this see one of the mesecon issues i've linked> My fps started jittering like crazy and cpu usage was like at 100% but max lag was still at 0.2~0.3 But the real problem could arise when serializing memory or doing massive amounts of interrupts/digiline messages because that gets done after the execution and isn't ratelimited So the serializer abuse bug [that i cannot reproduce] could probably be used in the async_controller |
Any interrupt stuff does not have to be fixed because there's configuration for its behavior. Anything you can just push to queue can create issues, for interrupt you can disable queue so for 200 luacs it is always at most 200 active interrupt any given time. |
For serialization issues make sure you validate asynchronously and only return verified good results that have been already serialized. That takes overhead away from main thread and amount of data can be counted toward possible per luac execution limits. |
the issue wasn't with interrupts but the fact that i have interrupts + laggy code this issue can be solved by setting the execution time limit 5ms instead of 10ms for example, or like tracking down the lag machine (i have made a basic tool to track them down) |
that's what the luacontroller does in the remove_functions function (functions cannot be serialized and will crash minetest) the current problem is that the serialization can simply just take too much time,
i don't know how to reproduce it because the steps to reproduce that issue are private |
Additionally it would be good to integrate reporting for mesecons_debug mod |
I can't figure out how this mod works, but the only thing that my mod (and same with all the other controllers i think) seems to lack support for is their node timer override also my "basic tool" is just logging where an event happened and how many ms it took |
Have you tested/considered how this node works when e.g. jumped with jd? |
It actually collects data about any mesecons/digilines activity everywhere and adjusts delays for queues based on usage per mapblock. For this to work it somehow needs information about how long program execution actually took but it does not take into account that no main thread time were used. For other synchronous devices / wires / whatever stuff it is easy for debug mod to gain this information, anything asynchronous however will hide this information so it can't really know anything about async luac unless there's some kind of reporting from async luac to debug mod. |
When activated through the "execute" button, the mystery code i am not gonna show, but it seems there has been something done about it(?) since it says load:4: string length overflow but still caused a big lag spike, but mesecons_debug didn't seem to care (at least from /mesecons_hud) BUT when activated by another luacontroller with the code: if event.type=="program" then
digiline_send("","")
end It noticed something was fishy and registered a usage of So maybe it only monitors digilines and digiline/mesecons/luac related node timers So... should i just add the mesecons_debug's node timer override if mesecons_debug is avaliable (mooncontroller might have the same issue) |
I kinda want to make something where a user can make a library, and an async_controller can import it should i do this and how should i go about doing it, and where should the libraries be stored |
look at mooncontroller and the open issues. Re: wordlpath: everything before the mod-dir can be trimmed: /some/path/to/mods/mod/file.lua -> mod/file.lua |
or if you mean libraries like advtrain supports (user generated) modstorage would be a modern option for storing them. That could potentially allow all users to use each others code. Depending on the complexity you want to add, you could have a system with privs for reading and writing global code and you could also allow users to mark their code as private. |
so basically trim everything before the 2nd-to-last / |
|
one way is to use |
oh cool, that works |
also, now that i think about it adding user libraries might be a bad idea (because i feel it would be too complex to implement) so i guess now i should focus on like... security and improving the source code |
So i've rewired/rewritten the async_controller mod a bit, namely to use Also breaking changes:
Debugging improvements: you can now see how much the callback took (aka the part that processes all the digiline_sends, interrupts and saving memory) if you have enabled it in the source code
|
(Need to fix a really silly crash bug, eta: tmrw) fixed lol, why did i wait 3 weeks to post that update |
should i rewrite it to use my sandboxing mod |
looking back at this - i should probably rewrite it to use my sandboxing library |
Repo: https://github.com/TheEt1234/async_controller/tree/main
Problems:
Ratelimitingbasically solved, just need to figure out what to do if someone spams like 50 of them in a mapblock...
i think mesecons_debug can figure that one outit can'tAnd also needs more testing
Discussion (has some important context)
starts from https://discord.com/channels/513329453741637637/719950700485935145/1214324327185649684
For those without access to Discord, the discussion mentioned above, has been added to this thread.
The text was updated successfully, but these errors were encountered: