[JIRA] Commented: (HUDSON-2978) Checkstyle is taking too long to calculate the difference of warnigs

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[JIRA] Commented: (HUDSON-2978) Checkstyle is taking too long to calculate the difference of warnigs

Hudson issues mailing list

    [ http://issues.hudson-ci.org/browse/HUDSON-2978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=136348#action_136348 ]

weigo commented on HUDSON-2978:

The problem is the implementation of AnnotationDifferencer.difference(target, other).

It uses the removeAll operation on a clone of the target collection. This will loop over all elements in target and call the contains operation on the ohter collection with the current element as argument. So this can lead to O(n^2) performance of contains where it could be O(1).

The implementation should look like this:

Index: plugins/analysis-core/src/main/java/hudson/plugins/analysis/core/AnnotationDifferencer.java
--- plugins/analysis-core/src/main/java/hudson/plugins/analysis/core/AnnotationDifferencer.java (Revision 28050)
+++ plugins/analysis-core/src/main/java/hudson/plugins/analysis/core/AnnotationDifferencer.java (Arbeitskopie)
@@ -41,7 +41,7 @@
     private static Set<FileAnnotation> difference(
             final Collection<FileAnnotation> target, final Collection<FileAnnotation> other) {
         Set<FileAnnotation> difference = new HashSet<FileAnnotation>(target);
-        difference.removeAll(other);
+        difference.removeAll(new HashSet<FileAnnotation>(other));
         return difference;

This change leads to usable performance of the checkstyle view on modules with an overall warning count of ~84000. Before the patch it took about 6 minutes to compute the difference between two identical sets of the above size.

> Checkstyle is taking too long to calculate the difference of warnigs
> --------------------------------------------------------------------
>                 Key: HUDSON-2978
>                 URL: http://issues.hudson-ci.org/browse/HUDSON-2978
>             Project: Hudson
>          Issue Type: Bug
>          Components: checkstyle
>    Affects Versions: current
>         Environment: Platform: All, OS: All
>            Reporter: developster
>            Assignee: drulli
> We have a project that has a lot warnings (approx 100k warnings). Algorithm that
> does differentiation should be optimized a bit, because now it takes 30 minutes,
> this is incredible long.
> Thanks a lot for your efforts.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.hudson-ci.org/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]