function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
wyvernwyvern 

High CPU usage when processing result of SOAP retrieve call

I'm experiencing 100% cpu usage for about 14 seconds when I make a retrieve call on 2000 lead ids with the following list of fields: (line wrapped for easier reading)

Id,IsDeleted,MasterRecordId,LastName,FirstName,Salutation,
Name,RecordTypeId,Title,Company,Street,City,State,PostalCode,
Country,Phone,MobilePhone,Fax,Email,Website,Description,
LeadSource,Status,Industry,Rating,AnnualRevenue,
NumberOfEmployees,OwnerId,HasOptedOutOfEmail,
IsConverted,ConvertedDate,ConvertedAccountId,ConvertedContactId,
ConvertedOpportunityId,IsUnreadByOwner,CreatedDate,CreatedById,
LastModifiedDate,LastModifiedById,SystemModstamp,LastActivityDate,
DoNotCall,HasOptedOutOfFax,LastTransferDate,EmailBouncedReason,
EmailBouncedDate,SICCode__c,ProductInterest__c,Primary__c,
CurrentGenerators__c,NumberofLocations__c

So, more than a few fields, but still not all that many...

All network traffic for the call is in a burst at the start of the 14 second cpu usage spike, so it appears that the CPU usage is all in the actual processing of the message. Is this normal? That would mean that the rate of converting the XML into SObjects is less than 200/s, which seems very slow. I'm on a Core 2 Duo 2.1GHz box. Any ideas what I might be doing wrong, or is it really just that slow? Should I use a different SOAP toolkit?

I'm using the Partner WSDL v13 with the JAX-WS reference implementation 2.1.4 SOAP toolkit. The soap stub objects were generated with JAX-WS's wsimport ant task. I'm using the following JAXB binding (found on these forums, actually) to work around a class name clash:
Code:
<bindings
  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns="http://java.sun.com/xml/ns/jaxws">
  <bindings
    node="//xsd:schema[@targetNamespace='urn:partner.soap.sforce.com']">
    <jaxb:globalBindings
      underscoreBinding="asCharInWord" />
    <jaxb:schemaBindings>
      <jaxb:nameXmlTransform>
        <jaxb:typeName
          suffix="Type" />
      </jaxb:nameXmlTransform>
    </jaxb:schemaBindings>
  </bindings>
  <enableWrapperStyle>false</enableWrapperStyle>
  <enableAsyncMapping>false</enableAsyncMapping>
</bindings>

 

wyvernwyvern
I also tried using the Apache CXF soap stack and had exactly the same CPU usage problem (14-15s of 100% cpu).
SuperfellSuperfell
Are you running with a small heap, and therefore spending all your time thrashing in GC?
wyvernwyvern
It doesn't appear so: I let it run for about 6 minutes and spent about 20s in GC. More than I'd like, but not necessarily thrashing. The max heap was 900MB during that time, according to jconsole. This is on jdk 6 update 7.
wyvernwyvern
So, no ideas on why I'm getting the high CPU, then? I'm kind of stuck until I figure out how to mitigate this. I can parallelize the calls across multiple cores, but obviously it'd be even better to speed it up regardless of parallelization.
SuperfellSuperfell
Its going to be a function of the xml parser & soap stack you're using.
wyvernwyvern
Yeah, I guess I'll ask on the JAX-WS boards. Thanks for your help.