commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Damjan Jovanovic <dam...@apache.org>
Subject Re: [COMPRESS] SevenZFile - fix debug so boxing is eliminated?
Date Wed, 22 May 2013 14:46:18 GMT
On Tue, May 14, 2013 at 2:36 AM, sebb <sebbaz@gmail.com> wrote:
> The private debug method requires an array of Objects to be passed to
> System.out.format.
>
> Any primitive parameters will be autoboxed.
>
> However, the boxing will be performed regardless of whether DEBUG is
> true or not.
> This is a bit wasteful as DEBUG is false by default.
>
> It may be better to inline the debug method calls.


Autoboxing into Object varargs which are never used is still cheaper
than conversions and concatenations into a single String that's never
used, which is why slf4j and log4j2 provide it. But either way, a good
compiler should be able to inline debug(), then eliminate the dead
logging code because private static final boolean DEBUG is hardcoded
to false, then optimize all the variables and expressions out of
existence (since they never get read). Even if Hotspot doesn't
optimize that well (and I think it does since assert() supposedly
costs 0 when "-ea" is absent), the performance-critical path of
decompressing file contents doesn't log.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message