From f8b5ae45f1fae9a79b33d88527bd8812a3d6c249 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 29 Jul 2014 21:48:14 -0230 Subject: [PATCH] Make LogContext optional. This can be useful for debugging mod issues, but Apache's implementation in log4j2 is responsible for a very significant % of the overall runtime. Quite frankly this is shockingly bad performance from what is supposed to be a high performance logging framework. Anyway, until we can figure out if we can fix it, we're turning it off by default. --- .../cpw/mods/fml/common/eventhandler/ASMEventHandler.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fml/src/main/java/cpw/mods/fml/common/eventhandler/ASMEventHandler.java b/fml/src/main/java/cpw/mods/fml/common/eventhandler/ASMEventHandler.java index 713d21b636..73a6c3f151 100644 --- a/fml/src/main/java/cpw/mods/fml/common/eventhandler/ASMEventHandler.java +++ b/fml/src/main/java/cpw/mods/fml/common/eventhandler/ASMEventHandler.java @@ -22,6 +22,7 @@ public class ASMEventHandler implements IEventListener private static final String HANDLER_FUNC_DESC = Type.getMethodDescriptor(IEventListener.class.getDeclaredMethods()[0]); private static final ASMClassLoader LOADER = new ASMClassLoader(); private static final HashMap> cache = Maps.newHashMap(); + private static final boolean GETCONTEXT = Boolean.parseBoolean(System.getProperty("fml.LogContext", "false")); private final IEventListener handler; private final SubscribeEvent subInfo; @@ -36,11 +37,11 @@ public class ASMEventHandler implements IEventListener @Override public void invoke(Event event) { - if (owner != null) + if (owner != null && GETCONTEXT) { ThreadContext.put("mod", owner.getName()); } - else + else if (GETCONTEXT) { ThreadContext.put("mod", ""); } @@ -51,7 +52,8 @@ public class ASMEventHandler implements IEventListener handler.invoke(event); } } - ThreadContext.remove("mod"); + if (GETCONTEXT) + ThreadContext.remove("mod"); } public EventPriority getPriority()