Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow Aggregate Report Performance / org.apache.jorphan.math.StatCalculator #2236

Closed
asfimport opened this issue May 19, 2009 · 1 comment
Closed

Comments

@asfimport
Copy link
Collaborator

Jared Sulem (Bug 47223):
JMeter slows to a crawl and eventually becomes completely unresponsive as it accumulates samples using the Aggregate Report.

The issue appears to be that the StatCalculator uses an ArrayList to store the samples and inserts them within the list to keep the list sorted. ArrayList has O(n) performance for insertions at arbitary locations in the array (n is the current size of the list). This means that over the entire JMeter run performance of JMeter with an AggregateReport is at least O(n-squared).

Changing the ArrayList to a LinkedList significantly improves the performance. Although a LinkedList is still O(n) for sorted insertions (and for operations such as reading the median and 90% values), the constants for these operations are significantly lower than that of inserting into an ArrayList (probably because the LinkedList never needs to copy the whole array in order to insert an item).

After this change JMeter becomes usable for collecting tens of thousands of samples, whereas before it would bring my system to a complete halt.

I've attached a small patch to the bug that changes the ArrayList into a LinkedList in StatCalculator.

Created attachment aggregate_report_performance.patch: Use LinkedList instead of ArrayList in org.apache.jorphan.math.StatCalculator

aggregate_report_performance.patch
Index: src/jorphan/org/apache/jorphan/math/StatCalculator.java
===================================================================
--- src/jorphan/org/apache/jorphan/math/StatCalculator.java	(revision 764194)
+++ src/jorphan/org/apache/jorphan/math/StatCalculator.java	(working copy)
@@ -18,7 +18,7 @@
 
 package org.apache.jorphan.math;
 
-import java.util.ArrayList;
+import java.util.LinkedList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -29,7 +29,7 @@
  * not threadsafe.
  */
 public class StatCalculator {
-    List values = new ArrayList();
+    List values = new LinkedList();
 
     double sum = 0;
 

Votes in Bugzilla: 1
Severity: normal
OS: Linux

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Thanks for the report and patch. Fixed in SVN:

URL: http://svn.apache.org/viewvc?rev=805481&view=rev
Log:
#2236 - Slow Aggregate Report Performance (StatCalculator)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant