-
Notifications
You must be signed in to change notification settings - Fork 2k
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
DISCUSS: Lua time budget for MapGen #12003
Comments
Tried with a custom fair mutex implementation. That did not give the desired result. I expected that as long as the server thread can get in in order requested it would alleviate the problem. That was not the case. |
BTW The following config properties do not do what they are described to do:
At the time the blocks are enqueued for emerge we do not know whether they need to be generated or not. Does someone know why we want different limits in these cases? (Again this does not limit generations and disk loads separately). |
I am pretty sure server owners might want to limit lag from players exploring new areas. Is this not usable for that purpose? |
The reason for that is most likely the village generation, which lags literally everything else because it tries to work around the mapgen griefing already placed structures by overwriting the same mapblock up to 8 times (ask @kay27 for details about it). @corarona has found a way to fix this by means of moving the village generation out of the map generator into “structure blocks” that get placed by the mapgen and turn into a village by means of an ABM: https://git.minetest.land/Mineclonia/Mineclonia/commit/e3b8e1a826d8e670db6e96288ef86c3d6ed7ab2b Edit: I have found no other village generator that lagged the game as much as the one in MineClone2, even ones that have much more complex structures have caused no noticeable lag for me. I therefore think it is not necessary to fix this in the engine and that MineClone2 village generation should be fixed instead. |
@erlehmann Thanks for looking In general I'm trying to improve load/lag on the servers. I'm actually not sure how servers could ever scale to any reasonable view_range and player counts before all of these... This is a continuation of those efforts.
Yes. And that you do with max_block_generate_distance.
I get 1, 2. And I get some combo of 3 and 4. But 3 and 4 are weird.
That works precisely because ABM Lua has a time budget of 200ms per second. :) That leaves budget for other Lua to run (entities, etc). I though I can play with the emerge queue limits (such as lowering the generate limit), but these are useless for that. Edit: Spelling. |
Oh but I disagree! The engine should provide a modicum of protection just like we do for ABMs. Should we remove ABM time budgets and just tell mod owners to fix their code when ABM introduce lag? |
afaik mcl villages are pretty much the settlements mod (https://gitlab.com/Rochambeau/settlements) which, if i remember correctly did mention these freezes somewhere. Can't find where exactly rn though. |
Might as well they will just use node timers if abms aren't slow enough :). Jk i think that is a good idea. |
Thinking about how to do this now. Fair-locking already failed :( |
This isn't as simple as it sounds. Stopping Lua mid execution is hard, In the end the real solution is still #3182. |
Yeah... I know. I think we do not need to break mid-lua (we do not do that for ABMs) to get some mileage. #3182 is a lot of work to get right, though, especially without breaking stuff. You think it's not worth pursuing? |
I'd rather go straight for the right approach but that doesn't mean something couldn't be found to minimize mapgen lag. |
Well, it's probably MCL2. It currently more likely in unmaintained state. This lag arose from, among other things, the fact that we released MCL2 0.71 in sync with 5.4, I debugged the code on two engine versions for two sleepless weeks, as a result, villages emerge much larger than they actually need, and generally buggy :( Please notify if you will occasionally notice the same lag in mcl5, though villages are under performance optimization, see #12042 |
Closing this since the discussion is over and we know what the right approach is. |
Problem
Server lag continues to be a problem.
Sources are:
Map Save is somewhat mitigated by using zStd now, which is much faster at writing.
Lua on behalf of ABMs is already limited (default 200ms) per ABM interval (default 1s)
Lua for MapGen is not limited, and thus is a known cause of unlimited server lag. The more clients, the more customer Lua, and the more EmergeThreads... The higher the lag. I've seen 10-20s lag due to MapGen with MineClone with multiple EmergeThreads.
We also have assumptions in the code about maximum lag. For example collisionMoveSimple assumes lag < 0.5s or results will be incorrect leading to stuttering on the client (as client and server make different predictions).
Solutions
Limit MapGen Lua the same (or similar) as we limit ABM lua, 200ms per second, or similar.
The details are tricky as there is a single queue for emerging whether a block is loaded or generated. We do not want to stall loading.
I'd have to think whether two queues are fine 1 for generate requests and 1 for load requests. And dedicated threads for each. Does anyone see a problem offhand with that?
Alternatives
2. Fair locks would probably go a long way.
Ask
Let's have a discussion here.
The text was updated successfully, but these errors were encountered: