| By Huang Chang Hao | Article Rating: |
|
| January 2, 2009 07:15 AM EST | Reads: |
2,953 |
One day, I received an e-mail from a customer complaining that there was 100% CPU occupancy on our program, EDC (Engineering Data Collection) service, while handling certain XPath queries. Well, that specific XPath was really a bit complicated as you can see:
//CDResults[../../../TargetName/@Value=//SiteInformation[TargetName/@Value!=//SiteInformation[1]/TargetName/@Value and TargetName/@Value!=//SiteInformation[TargetName/@Value!=//SiteInformation[1]/TargetName/@Value][1]/TargetName/@Value][1]/TargetName/@Value]/BottomCD/@Value
I decided to do some tests on the program and some other alternative solutions. I set two goals for this test:
- To verify if the XML parser is the part causing 100% CPU usage.
- If so, to try to find alternative solutions for better performance.
Methodology
A test program was built to implement four different solutions but achieve the same functionality, which was to retrieve the value of a given XML based on a certain XPath query. The four solutions included the current implementation in the EDC service and three alternatives. The major difference among these four solutions was:
- Solution 1: Implements XmlDocument and XPathNavigator.Evaluate
This was the current implementation in EDC service. - Solution 2: Implements XPathDocument and XPathNavigator.Evaluate
- Solution 3: Implements XPathDocument and XPathNavigator.Select
- Solution 4: Implements XmlDocument.Select
Timestamps were recorded at the beginning and end of each solution. Then, the time span for each solution was calculated. All this information was stored in a log file. A CPU usage history graph was captured to illustrate the difference between the solutions. Data analysis and extra study and research was conducted after each test was done and the data become available.
Test Environment
- Desktop Computer: Dell OptiPlex GX270
- CPU: Intel Pentium 4 / 2.8GHz
- RAM: 1G
- Windows 2000 Professional v5.00.2195
- Service Pack 4 Build 2195
- .NET framework 1.1 v1.1.4322 SP1
- Visual Studio 2003 v7.1.6030
Raw Data
The source code can be downloaded from here.
- XML file: see VeritySEM_WAFER_REPORT_5.xml
- XPath query string:
//CDResults[../../../TargetName/@Value=//SiteInformation[TargetName/@Value!=//SiteInformation[1]/TargetName/@Value and TargetName/@Value!=//SiteInformation[TargetName/@Value!=//SiteInformation[1]/TargetName/@Value][1]/TargetName/@Value][1]/TargetName/@Value]/BottomCD/@Value
- Dummy Large XML: see testBigXML.zip
Test Result and Analysis
CPU Usage
The CPU occupancy rose to 100% immediately after the test application started. It could confirm that the 100%-CPU-usage issue is caused by the XML parser (see Figure 1).
Result of Each Solution
All four solutions ran correctly and got the same result: 9.161745E-02. So all the solutions are workable.
All four solutions mean 100% CPU usage, but a dramatically different time to finish. I ran the test program twice. Table 1 illustrates the time used for each solution during the two runs.
- Time format is HH:MM:SS
- First run ran under Visual Studio debug mode
- Second run ran after the program was compiled as a standalone executable.
Published January 2, 2009 Reads 2,953
Copyright © 2009 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Huang Chang Hao
Huang Chang Hao is a senior software engineer working at Qimonda IT Suzhou Ltd., Co. His main expertise is semiconductor FAB automation software, Equipment Integration and Manufacturing Execution System.
- Kindle 2 vs Nook
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- Confessions of a Ulitzer Addict
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- It's the Java vs. C++ Shootout Revisited!
- Cloud Computing Can Revitalize Your Career as Software Developer
- IBM Could "Reinvent" Java: Mills
- Oracle & Cloud Computing: Exclusive Q&A with SVP Richard Sarwal
- A Brief History of Cloud Computing
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- The i-Technology Right Stuff
- JavaServer Faces (JSF) vs Struts
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- What's New in Eclipse?
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- i-Technology Predictions for 2007: Where's It All Headed?






































