It does not make sense I agree. I tried again and it does not show up. I think I must have not had the updated config file deployed to the remote VM I used for testing... sorry about the noise.
The Log4j hot spot that does show up in my current config is AbstractLogger.isTraceEnabled() for 2.3% of CPU. I do not quite see how to make the meat of that faster. I wonder how much time would be saved if the config file check is migrated to a Java 7 file watcher? I do have the refresh check set to the min value of 5 seconds. Gary On Wed, Jul 8, 2015 at 9:13 PM, Ralph Goers <[email protected]> wrote: > How can CompositeFilter.filter() show up as a hot spot if you don’t have > any filters at all? > > Ralph > > On Jul 8, 2015, at 4:26 PM, Gary Gregory <[email protected]> wrote: > > More data, it must have been a fluke because CompositeFilter.filter() > still shows up high in the hot spot list of methods called. I do not have > any Filter XML in my config... > > Gary > > On Wed, Jul 8, 2015 at 4:20 PM, Gary Gregory <[email protected]> > wrote: > >> Hi All: >> >> I am now profiling my JDBC driver and I was surprised to see Log4j's >> CompositeFilter.filter() show up at 0.9% of CPU time when I had logging set >> to INFO which only logged two events for the whole test run. The driver >> does a lot of flow tracing at the TRACE level so Log4j gets called _a lot_. >> >> In my XML config, I have a Filters element with a bunch of Filter child >> elements.When I am debugging, I comment some filters in and out. Most of >> the time, I am not debugging, so I have all the individual filters >> commented out. The top level Filters element is still there. >> >> If I completely remove all filters from the config (no Filters element), >> then the CompositeFilter disappears from profiling. >> >> Now that I've looked at the code, I see that the behavior is explained by: >> >> @PluginFactory >> public static CompositeFilter createFilters(@PluginElement("Filters") >> final Filter[] filters) { >> final List<Filter> filterList = filters == null || filters.length >> == 0 ? >> new ArrayList<Filter>() : Arrays.asList(filters); >> return new CompositeFilter(filterList); >> } >> >> An XML fragment like <Filters></Filters> always creates a CompositeFilter >> even though there is nothing to filter. >> >> I'm not sure what is the best way to fix this. The CompositeFilter could >> accept a null and treat it specially (not pretty or effective since >> filter() still gets called a gazillion times). Ideally, the createFilters >> should not even be called in the empty Filters element case. >> >> This is too nasty and obscure to put in the FAQ so I'd like to discuss >> how to fix it. >> >> Thoughts? >> >> Thank you, >> Gary >> >> -- >> E-Mail: [email protected] | [email protected] >> Java Persistence with Hibernate, Second Edition >> <http://www.manning.com/bauer3/> >> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> >> Spring Batch in Action <http://www.manning.com/templier/> >> Blog: http://garygregory.wordpress.com >> Home: http://garygregory.com/ >> Tweet! http://twitter.com/GaryGregory >> > > > > -- > E-Mail: [email protected] | [email protected] > Java Persistence with Hibernate, Second Edition > <http://www.manning.com/bauer3/> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > Spring Batch in Action <http://www.manning.com/templier/> > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory > > > -- E-Mail: [email protected] | [email protected] Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> Spring Batch in Action <http://www.manning.com/templier/> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
