Request for review: Race conditions in java.nio.charset.Charset
Ulf Zibis
Ulf.Zibis at gmx.de
Wed Oct 7 22:58:41 UTC 2009
Martin, thank for your review.
Am 08.10.2009 00:01, Martin Buchholz schrieb:
> IIRC correctly, I am the author of the hacky 2-element charset cache.
> Certainly improvements can be made, but it's hard to balance
> memory usage vs. the cost and complexity of writing a good cache.
>
I guess, the memory usage of 2-element class CharsetItem is equivalent
to 2-element Object[].
> I agree with Sherman that a race in the cache itself is not a bug
> (or at best, a performance bug).
>
For my better understanding:
Can you explain me the real bug in
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6881442.
In my understanding, loading the "name" field twice is too only a
performance bug. Please correct me!
> I don't think it's worth a point fix here unless an actual wrong result
> can be demonstrated. I do think a more sophisticated charset cache
> would be good, but hard to get right.
>
The other point is the size of the cache, see
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6795535.
I have logged the usage of the Charset.lookup() method from a simple
test which has only called ISO-8859-1 and IBM037 . As you can see, UTF-8
and cp1252 (default encoding on German Windows) is frequently requested
from the VM, so IMO size 2 is too restrictive (note the different
aliases UTF-8, utf-8 and UTF8):
UTF-8
utf-8
UTF-8
Cp1252
UTF-8
UTF-8
UTF-8
UTF-8
UTF-8
UTF-8
UTF8
UTF8
Cp1252
Cp1252
Cp1252
Cp1252
Cp1252
Cp1252
Cp1252
Cp1252
Cp1252
Cp1252
Cp1252
Cp1252
UTF-8
IBM037
UTF-8
UTF-8
utf-8
ISO-8859-1
UTF-8
-Ulf
More information about the core-libs-dev
mailing list