Sting interning: test cases wanted.

David Megginson david at
Fri Jan 14 20:51:12 GMT 2000

Miles Sabin <msabin at> writes:

> Doug Lea (Java concurrency guru, for those of you who don't
> recognize the name) has very generously offered to run some 
> String.intern() benchmarks on a 4 way Sun box to give us a bit
> of empirical input into this debate.
> All we have to do is come up with plausible test cases. They
> needn't (in fact, probably shouldn't) be full blown parsers and
> handlers, just typical patterns of String.intern(),
> String.equals() and ==, which can be looped and replicated
> across a variable number of threads.

Why not try the real thing?

Download Microstar's AElfred XML parser from

By default, this parser doesn't use java.lang.String.intern in its
intern functions.  Look for the following line in (on
or about line 2,413):

				// OK, add it to the end of the
				// bucket.
    String s = new String(ch, start, length);

Make a second copy and change it to read

				// OK, add it to the end of the
				// bucket.
    String s = new String(ch, start, length).intern();

Get the biggest batch of XML documents you can collect (or set up
scripts to generate some dynamically from whatever data structures you
can get your hands on, even system calls) and build your test
architecture: four parsers running in parallel, each processing
documents in serial: first with the original version of AElfred, then
with the modified version.

It will be very interesting to see the results.

All the best,


David Megginson                 david at

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as: or CD-ROM/ISBN 981-02-3594-1
Please note: New list subscriptions now closed in preparation for transfer to OASIS.

More information about the Xml-dev mailing list