Re: String interning (WAS: SAX2/Java: Towards a final form)
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!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format