Patch to Throwable and StackTraceElement (reduced CPU usage)

mike.skells at talk21.com mike.skells at talk21.com
Sun Oct 9 22:00:40 UTC 2011


Hi All,
It has always irritated me that they create so many temporary objects. The patch reduces the number of StringBuilders that are created (originally 2 for each stack trace element)


The patch reuses the StringBuilder and only sends text to the underlying stream for every line. 

It could be optimised to run faster by sending updates of more than one line but that would change the memory footprint so this seemed a good compromise.


I include the patch, a micro-benchmark and the results of the micro-benchmark which show an improvement of 80% throughput (ie it is almost twice as fast)

Regards

Mike
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: TestThrow.java
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20111009/0070592c/TestThrow.java>


More information about the core-libs-dev mailing list