[Bug 239] New: performance issue in MessageFormatter

http://bugzilla.slf4j.org/show_bug.cgi?id=239 Summary: performance issue in MessageFormatter Product: SLF4J Version: 1.6.x Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P1 Component: Core API AssignedTo: slf4j-dev@qos.ch ReportedBy: kite668@mail.ru 1. org.slf4j.helpers.MessageFormatter.arrayFormat uses localy thread-safe StringBuffer instead of StringBuilder. I think it can be safely replaced. 2. "deeplyAppendParameter(sbuf, argArray[L], new HashMap());" - this is called for EVERY argument, even if it isn't array. I think instance of HashMap shouldn't be created for every argument. You can pass null and initialize HashMap in deeplyAppendParameter only for object's arrays and if it's previous value is null. Also you can initialize this map with initial capacity = array's size. 3. It will be very good if method arrayFormat would receive StringBuilder instead of creating instance of result String. This is common and more fast solution. -- Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.

http://bugzilla.slf4j.org/show_bug.cgi?id=239 Joern Huxhorn <joern@huxhorn.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |joern@huxhorn.de --- Comment #1 from Joern Huxhorn <joern@huxhorn.de> 2011-09-05 08:55:43 CEST --- SLF4J is supposed to be 1.4-compatible so StringBuilder is not an option. -- Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.

http://bugzilla.slf4j.org/show_bug.cgi?id=239 --- Comment #2 from Roman Kosenko <kite668@mail.ru> 2011-09-05 11:29:25 CEST --- In this case (in order to support legacy JDK) I think slf4j should be shipped in several version (like this: http://www.firebirdsql.org/en/jdbc-driver/). Or use independent realization - own or, for example, http://javolution.org/target/site/apidocs/javolution/text/TextBuilder.html -- Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.

http://bugzilla.slf4j.org/show_bug.cgi?id=239 --- Comment #3 from Simon Arlott <bugzilla.slf4j.simon@arlott.org> --- Created attachment 98 --> http://bugzilla.slf4j.org/attachment.cgi?id=98&action=edit Patch to fix 2 of the 3 reported issues 1. SLF4J 1.7.x requires Java 1.5, so use StringBuilder 2. Create HashMap on demand in deeplyAppendParameter() with the default map size because the array size is not an indicator of how many map keys will be put without knowing how many elements are also object arrays 3. Not implemented as the Logger interface only accepts a format String, not a StringBuilder -- You are receiving this mail because: You are the assignee for the bug.
participants (2)
-
bugzilla-daemon@pixie.qos.ch
-
bugzilla-daemon@qos.ch