xalan-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Boden (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (XALANJ-1544) AttributesImplSerializer slow for low number of attributes
Date Fri, 24 May 2013 14:10:20 GMT

    [ https://issues.apache.org/jira/browse/XALANJ-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13666340#comment-13666340

David Boden commented on XALANJ-1544:

Hi. I have a program which has 17 attributes per element for a large number of elements, so
it just breaks through the limit of 12. I've raised an Oracle JDK request for enhancement
(2512518) to make the number a bit more flexible. I find that the switch to HashMap significantly
reduces the performance of my application.

Here's the text in the request for enhancement:

The com.sun.org.apache.xml.internal.serializer.AttributesImplSerializer contains an optimisation
for XML elements with a large number of attributes.

It extends the AttributesImpl class and changes behaviour when over 12 attributes are to be
stored in an element. The 12 is hardcoded in the class with a comment of:

This is the number of attributes before switching to the hash table, and can be tuned, but
12 seems good for now - Brian M.

I have a use-case with 300,000 conversions with exactly 17 attributes each. The memory and
garbage collection performance of my application is severely reduced when going from less
than 12 to more than 12 attributes. The optimisation creates large numbers of new strings
and hashmap entries within the switchOverToHash() method. This shows up in JVisualVM as the
largest task that's taking place.

The SerializerBase class contains:
protected AttributesImplSerializer m_attributes = new AttributesImplSerializer();

This provides no opportunity to use the simpler AttributesImpl instead. There's also no way
to change the hardcoded number 12.
> AttributesImplSerializer slow for low number of attributes
> ----------------------------------------------------------
>                 Key: XALANJ-1544
>                 URL: https://issues.apache.org/jira/browse/XALANJ-1544
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.
 Anybody can view the issue.) 
>          Components: Serialization
>    Affects Versions: 2.7.1
>         Environment: Operating System: Other
> Platform: Other
>            Reporter: Brian Minchau
>         Attachments: ASF.LICENSE.NOT.GRANTED--AttributesImplSerializer.patch.txt
> org.xml.sax.helpers.AttributesImpl is faster for a low number of attributes, 
> but it has a linear search for getIndex(String qname) makes it Order N*N as N 
> attributes are added, so some things ran VERY slowly.  
> AttributesImplSerializer has a Hashtable to speed this up for large N, but it 
> is about twice as slow for small N.  Suggest a hybrid solution that only uses 
> the Hashtable after 10 or so attributes have been added.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org

View raw message