On Tue, 28 Dec 2004, Ceki Gülcü wrote:

| Anyway, a non-trivial amount of thinking went into the implementation of
| the equals() method. In the absence of a malevolent adversary, it is also
| correct although only probabilistically so. Its only downside is the
| addition of the static sequenceCount field and the sequenceNumber field in
| LoggingEvent.

How often is this number increased?

LoggingEvent sounds like a thing that is made for every log-invocation
that goes through (that is, that the log-call's level is above or equal to
the category's level, and these evaluations).

If that is so, then having a synchronized method -on the class- sounds
like a noticable synchronization impact, if you log much. A synchronized
block is in itself somewhat expensive, but in a multi threaded application
(e.g. Servlet Container), if two synchs happen to "hit" (e.g. on a
multi-CPU, or HT, or even on a normal preemptive multitasking OS), then
the contention time might become, as I've understood it, "very" high. Thus
it is interesting to avoid global synch-bottelnecks.

Isn't there some synchronization going on anyway when a log-invocation
goes through, on the Category and Appender levels?  Couldn't this
LoggingEvent sequenced number be made at the same time, avoiding the
additional synch block? Maybe one could use some Category Id (if there is
such a thing, if not, maybe make it - this won't be an impact), and add a
category-local sequenced number (one of them multiplied by some 10^a
constant, to give two separate spaces). This would reduce the global
contention, at least it wouldn't introduce any more synchs.

Java 5.0 have synchronization contention monitoring accessible from within
the application - maybe some unit tests could be devised?
java.lang.management.ThreadMXBean.


PS: I agree that the name should be changed if it really shouldn't reflect
the sequence of the LoggingEvent, but merely is used as an equals-device.
Maybe call it logginEventUniqueId or something like this..

PPS: How much synchronization have gone into log4j? Ideally, I guess, it
should -only- synchronize on Logger.getLogger() and when actually doing
the appending?

Endre


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to