LOOHP/Bookshelf

Suggestion about performing a blocking I/O operation on the main thread

Closed this issue · 1 comments

Hi, I found this suggestion from another spigot plugin called Lagmonitor : Make stop the plugin from doing a blocking I/O operation on the main thread because this could affect the server performance, the thread pauses until it gets the response. Such operations should be performed asynchronous from the main thread. Besides gameplay performance it could also improve startup time.

In this case looks like this happen when the server is closing up.

Bookshelf Version: 3.1.0.0 / Server: Purpur-1762 (MC: 1.19.2) (Implementing API version 1.19.2-R0.1-SNAPSHOT) (Git: 39e30d6 on HEAD).

Log: https://logs.apexminecrafthosting.com/csrUedH

Thanks =D

LOOHP commented

Short answer: It should be fine, since server closing does not affect "gameplay performance" nor is it during "start up"
Long answer: Saving on the main thread is done on purpose on server shutdown. If you are wondering, bookshelf saves while the server is running are being done asynchronously all the time, it is only during shutdown that they are saved on the main thread. This is to make sure that all bookshelves are saved before the server fully closes, as the server does not wait for asynchronous threads to complete before closing, it only finishes up tasks on the main thread.