-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Konstantin,

On 11/23/11 1:21 PM, Konstantin Kolinko wrote:
> 2011/11/23 Christopher Schultz <ch...@christopherschultz.net>:
>> On 11/23/11 11:29 AM, Caldarale, Charles R wrote:
>>>> From: Christopher Schultz
>>>> [mailto:ch...@christopherschultz.net] Subject: Babysitting
>>>> ThreadLocals
>>> 
>>>> Removing the ThreadLocal after every request of course means
>>>> that the use of ThreadLocal is entirely useless.
>>> 
>>>> Should I stop worrying about the overhead of creating a 
>>>> SimpleDateFormat?
>>> 
>>> Given that the cost of generating and writing a log entry is
>>> going to vastly outweigh any object creation or synchronization
>>> impact, then, yes, you should stop worrying.
>> 
>> External reality checks are always useful. ;)
> 
> The yyyy-MM-dd value changes only ~365 times a year. You do not
> need to regenerate it every second.

Correct. This is only the code for "protecting" the SimpleDateFormat.

> Tomcat does some clever things when it needs to generate timestamp
> for logging purposes (e.g. in org.apache.juli.OneLineFormatter),
> but that looks like an overkill for your use case.

I actually got the idea of using ThreadLocal from Tomcat's logging
code. Tomcat has the distinct advantage of being loaded at a higher
ClassLoader level and therefore won't leak its own ThreadLocals across
webapp restarts :)

I think most of this will be overkill, at least for the minimal load
we're getting as of now. If we were talking more than maybe 50
requests per second I might start looking at ways to reduce memory and
CPU overhead for this kind of thing. But Chuck is right: the disk is
the bottleneck, here, and probably always will be until we move to a
more message-oriented logging scheme (where the disk on the other end
will be the bottleneck) :)

Thanks,
- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7PqfwACgkQ9CaO5/Lv0PA4iACeIKmdDmj5mr3yORb+h0+G2LDy
Tz8An0R13Akuc1NnxHfuvfWU24G1i5g+
=EvD/
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to