On Wednesday 28 Mar 2012 19:56:19 postwall-freenet at yahoo.de wrote:
> If I remember right then the main issue with debug logging wasn't GC but that 
> generating some of the log string arguments in freenet was simply very 
> resource intensive in itself. 

I'm not sure. I do remember it greatly increased CPU usage, but I also remember 
spending a long period chasing memory churn issues.

> So if Java isn't somehow intelligent enough to detect that argument x isn't 
> needed since it won't be used in the end anyway and thus doesn't evaluate it 
> before passing the value, then removing the current logic will cause higher 
> ressource usage once again.
> 
> In 'log.info("Random message: %s", obj.toString())' evaluating 
> 'obj.toString()' was what caused issues, not recycling it, or so I believe to 
> remember.

You don't need to call obj.toString() before calling log() - just pass the 
object itself. Then the only overheads are:
1) Calling the function, including passing the arguments - which hopefully will 
be optimised to be on some stack (but the code might not have been JITted yet).
2) Looking up whether it needs to be logged.

This means performance may be acceptable, though it'd need to be tested.
> 
> The main things causing GC issues which I remember were not reusing threads 
> and spawning a few new objects per received and send packet, not the log 
> stuff, that probably just tipped things over the edge when GC was already 
> done heavily because of the former.
> 
> Speeking out of memory as a non Java-dev here, so ignore if applicable. :P
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20120330/a0c0f444/attachment.pgp>

Reply via email to