WorldEdit

WorldEdit

43M Downloads

Chunk up operations and make some asynchronous

LadyCailinBot opened this issue ยท 15 comments

commented

WORLDEDIT-2200 - Reported by root

Split off operations so that they can easily be chunked, and allow some to be asynchronously run when possible.

commented

Comment by Chris.Woo

It wouldn't work as a separate thread? Thought it would help haha

commented

Comment by sk89q

Nah. Minecraft won't wait for WorldEdit (or anything else) to make a change, so imagine a block is being set in the main thread, but halfway through, WorldEdit sets it too, but right before the main thread finishes setting it. Who knows what could happen, and that's just a relatively simple example. There are much more dangerous examples :)

Normally "thread-safe" code handles this by employing "locks" on regions of code, so only one thread or process can use it at one time. MC does not employ locks for the majority of it.

commented

Comment by Chris.Woo

Ah that makes sense! Still looking forward to the day that I can do 1 Mil operations without the server locking up :D

commented

Comment by Chris.Woo

Would this help?
Bukkit/CraftBukkit@53ad0cf

commented

Comment by wizjany

bumping the issue wont speed anything up

commented

Comment by Chris.Woo

And who are you? Anyways I havent looked at sk89q's codebase yet. From what I understand from making an OS, executing tasks like WE operations can be split into smaller, asynchronous, non-blocking chunks. If sk was going to make a class to do that, I'm not sure if he could use bukkit's class to be more robust and save on coding and testing time.

commented

Comment by wizjany

Dev here, Hi.

commented

Comment by Chris.Woo

Admin and avid scripter here, Hi. Nice to meet you :) Titles aside, if it's useful, it should be used. If not, then whatever.

commented

Comment by falkreon

The scheduling part is easy. Also, the scheduler you linked is hidden behind the OBC/NMS version-wall, so it's nearly useless to WorldEdit's team.

The problem with WorldEdit, my main problem, is that it's got a lot of deeply-ingrained code that does all its work in the same method, on the main thread, no matter how long it takes. This can displace the processing of player packets, effectively locking up the server until the operation finishes. Obviously the processing still needs to happen on the main thread, but once the code fully switches over to Operation and ColumnVisitor, it won't be too hard to control how much or how little of it gets done during a given tick.

Defnitely check out the operations-redux branch, and if you want it to happen faster, talk to these folks and write code that they're looking for.

commented

Comment by Chris.Woo

Why don't you move that section of the code to a processing task? It will take some refactoring, but this will allow you to feed in chunks to be processed. I'm not sure how much refactoring is needed to be done for this to work.

commented

Comment by wizjany

we have this under control, it's all planned and mostly written, we just have to get some time before it is finished
thanks for all your suggestions and so on, but they're really not necessary (also most people have no idea what they're talking about)

commented

Comment by sk89q

In progress again, with new branch
https://github.com/sk89q/worldedit/tree/visitor

Only this time, a bulk of the work is done.

commented

Comment by sk89q

The current work can be found in the branch:
https://github.com/sk89q/worldedit/tree/operations-redux

commented

Comment by Chris.Woo

I saw this in a bukkit build, would it help? "runTaskLaterAsynchronously"

commented

Comment by sk89q

Nah, because asynchronously means that it runs parallel with Minecraft, and Minecraft isn't built to handle that. It would completely break the server unfortunately.