[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: String interning (WAS: SAX2/Java: Towards a final form)

  • From: David Megginson <david@m...>
  • To: XMLDev list <xml-dev-digest@i...>
  • Date: 12 Jan 2000 14:08:04 -0500

interning in java
Miles Sabin <msabin@c...> writes:

> David Megginson has mentioned a way of reducing the overhead of
> java-interning: here we have a parser-internal map from 
> character sequences onto java-interned Strings ... 

This isn't just for reducing the cost of java interning: every
Java-based parser that actually has any kind of performance already
does this: otherwise, it could end up allocating tens of thousands of
new strings for even a medium-sized document.

[snip]

> Whilst this might improve things a bit, it's still a 
> performance hit: if the parser internal map is shared between 
> parsers then we have the same contention problem back again 

I haven't seen a parser that does it this way.

> (tho' this time in application code rather than the JVM); if it 
> isn't (and hence is parser-/thread-local), then it has to be 
> repopulated at least for each new parser instance, probably for 
> each new document. 

Once for every parser instance is usually sufficient.

> Even tho' this only requires one java-intern 
> for each distinct name it still provides plenty of 
> opportunities for synchronization collisions.

When you consider that even a long-ish document instance (say, 20,000
elements with an average of 3 attributes each) will likely contain
fewer than 50 unique element and attribute names (often fewer than
25), there are going to be too few invocations of
java.lang.String.intern to cause any serious problems.


All the best,


David

-- 
David Megginson                 david@m...
           http://www.megginson.com/

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ or CD-ROM/ISBN 981-02-3594-1
Please note: New list subscriptions now closed in preparation for transfer to OASIS.



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.