Switch the default asynchronous CallContext to ASYNCHRONOUS_TASK.

This will preserve the order of debug messages sent from multiple
threads. As a side effect, this might be better for performance, given
that on constant input the logging task will stay registered, so there
is little overhead and the file-io is taken off the asynchronous packet
and chat handler threads.Hopefully the thread switching is less
expensive than the gain by not delaying chat/packet threads, in case of
servers with few cores. We might adapt the used policy later, based on
cores and/or config.
This commit is contained in:
asofold 2015-10-18 18:31:52 +02:00
parent b179dba908
commit 4d59f67d34
2 changed files with 2 additions and 2 deletions

View File

@ -26,7 +26,7 @@ public class LogOptions {
ASYNCHRONOUS_DIRECT,
/** Always schedule to execute within a (more or less) dedicated asynchronous task. */
ASYNCHRONOUS_TASK,
/** Ensure it's logged asynchronously. */
/** Only log if it is not the primary thread. */
ASYNCHRONOUS_ONLY,
// CUSTOM_THREAD_DIRECT|TASK // Needs a variable (Thread, methods to sync into a specific thread would have to be registered in LogManager).

View File

@ -102,7 +102,7 @@ public class BukkitLogManager extends AbstractLogManager implements INotifyReloa
// TODO: Might attempt to detect if a thread-safe logging framework is in use ("default" instead of false/true).
boolean bukkitLoggerAsynchronous = config.getBoolean(ConfPaths.LOGGING_BACKEND_CONSOLE_ASYNCHRONOUS);
// TODO: Do keep considering: AYNCHRONOUS_DIRECT -> ASYNCHRONOUS_TASK (not to delay async. event handling).
CallContext defaultAsynchronousContext = CallContext.ASYNCHRONOUS_DIRECT; // Plugin runtime + asynchronous.
CallContext defaultAsynchronousContext = CallContext.ASYNCHRONOUS_TASK; // Plugin runtime + asynchronous.
// Server logger.
tempID = registerStringLogger(Bukkit.getLogger(), new LogOptions(Streams.SERVER_LOGGER.name, bukkitLoggerAsynchronous ? defaultAsynchronousContext : CallContext.PRIMARY_THREAD_TASK));