jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • XStream
  • XSTR-506

Method com.thoughtworks.xstream.mapper.FieldAliasMapper.key(Class,String) contains performance hotspot

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 1.2.2, 1.3
  • Fix Version/s: None
  • Component/s: Core
  • Labels:
    None
  • JDK version and platform:
    Sun 1.5.0_12 for Windows

Description

The profiling results for our application (which uses XStream 1.2.2 / 1.3) suggest that the keying mechanism used by the field alias mapper leads to a performance hotspot (in terms of execution time) due to the combination of the two factors number of invocations (the key method is called relatively often during serialization), and costs (in terms of execution time) per invocation, caused by the expensive string operations (implicit use of java.lang.StringBuffer – init, append, toString in the key method).

I recommend reworking the key mechanism so as to avoid using string operations. Maybe using the parameter object references as a key instead of concatenating their string representations could be a more efficient approach?

The number of calls to the key method could also be reduced in some instances, e.g. method shouldSerializeMember(Class definedIn, String fieldName) could first check whether fieldsToOmit is empty before constructing the key with which to search the hashset.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Java Source File
    FieldAliasingMapper.java
    02/Sep/08 6:10 PM
    4 kB
    Tatu Saloranta

Issue Links

is superceded by

Improvement - An improvement or enhancement to an existing feature or task. XSTR-517 Misc performance improvements (for detected HotSpots via profiler)

  • Minor - Minor loss of function, or other problem where easy workaround is present.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
Hide
Permalink
Tatu Saloranta added a comment - 02/Sep/08 6:09 PM

I noticed the same hot spot, and although it's not the biggest one (access to class/field info takes most of the time under 1.6 JVM), it pays off it to resolve this one too.
To that end, please see attached patch. Creating temporary key object is more efficient than constructing temporary strings.

Show
Tatu Saloranta added a comment - 02/Sep/08 6:09 PM I noticed the same hot spot, and although it's not the biggest one (access to class/field info takes most of the time under 1.6 JVM), it pays off it to resolve this one too. To that end, please see attached patch. Creating temporary key object is more efficient than constructing temporary strings.
Hide
Permalink
Tatu Saloranta added a comment - 02/Sep/08 6:10 PM

(see previous entry: here's performance improvement patch)

Show
Tatu Saloranta added a comment - 02/Sep/08 6:10 PM (see previous entry: here's performance improvement patch)
Hide
Permalink
Joerg Schaible added a comment - 18/Sep/08 3:31 PM

Superceded by XSTR-517

Show
Joerg Schaible added a comment - 18/Sep/08 3:31 PM Superceded by XSTR-517
Hide
Permalink
Joerg Schaible added a comment - 01/Dec/08 4:07 PM

Closed after receiving no further comment.

Show
Joerg Schaible added a comment - 01/Dec/08 4:07 PM Closed after receiving no further comment.

People

  • Assignee:
    Joerg Schaible
    Reporter:
    Stefan Wappler
Vote (0)
Watch (0)

Dates

  • Created:
    09/Jul/08 12:43 PM
    Updated:
    01/Dec/08 4:07 PM
    Resolved:
    18/Sep/08 3:31 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.