RFR: 8141211: Convert TraceExceptions to Unified Logging

Thomas Stüfe thomas.stuefe at gmail.com
Fri Dec 18 08:12:12 UTC 2015


On Thu, Dec 17, 2015 at 8:39 PM, Thomas Stüfe <thomas.stuefe at gmail.com>
wrote:

> Hi all,
>
> we at SAP have years ago added a logging system to our hotspot port which
> is in many ways similar to UL but solves the multiline-problem differently.
>
> (Side note: we are currently discussing whether to abandon our logging
> system in favour of UL, just because merging down- and upstream would be
> easier if we use the same logging system)
>
> In our system, we assemble the multiline content in memory and then print
> it in one go. Only during the printing part we lock (and only on platforms
> where we cannot be sure that one write call would not be atomic). The
> advantage is that locking is not responsibility of the caller.
>
> Basically, we have a Message class, which serves as message buffer to grow
> on demand (dynamically allocates C heap), with some care taken to balance
> number or (re)allocation calls and memory usage. The caller itself is
> responsible for adding newlines.
>
> Basically, it looks like this:
>
> Message mymsg = new Message;
> mymgs->print("hallo1\nhallo2\nhallo3");
> tracer->print(mymsg); <- here, tracer will lock, write, unlock
>
> When we print it, we precede the multiline message with the decorators in
> the first line and indent the rest of the lines to the same position:
>
> [time][pid][tid]  hallo1
>                   hallo2
>                   hallo3
>
> This approach has served us quite well. We decided against locking done by
> the caller because users to minimize the danger of deadlocks.
>
> Kind Regards, Thomas
>
>
Just wanted to add that one big advantage of buffering compared to locking
is that you do not influence timing as much.

With locking, you now introduce synchronization where before was none,
which even if it does not deadlock may change timing just enough to make
the error you are analyzing disappear.

Granted, logging causes File IO which also changes timing, but who says you
are always writing to files. If timing is really important, you could log
into shared memory or similar. But once locking is introduced in the log
system, it is difficult to get rid of again.

..Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20151218/1e9c69bd/attachment.html>


More information about the serviceability-dev mailing list