You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/05/09 12:21:00 UTC

[jira] [Work logged] (COLLECTIONS-770) ToString method is unresponsive after multiple SetUtils union calls

     [ https://issues.apache.org/jira/browse/COLLECTIONS-770?focusedWorklogId=767883&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767883 ]

ASF GitHub Bot logged work on COLLECTIONS-770:
----------------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/May/22 12:21
            Start Date: 09/May/22 12:21
    Worklog Time Spent: 10m 
      Work Description: stevebosman-oc opened a new pull request, #308:
URL: https://github.com/apache/commons-collections/pull/308

   Contributed on behalf of the @opencastsoftware open source team
   
   I am slightly wary of opening up UnmodifiableIterator, but this seems to solve the performance degradation of nested IteratorChains seen in COLLECTIONS-770
   
   




Issue Time Tracking
-------------------

            Worklog Id:     (was: 767883)
    Remaining Estimate: 0h
            Time Spent: 10m

> ToString method is unresponsive after multiple SetUtils union calls
> -------------------------------------------------------------------
>
>                 Key: COLLECTIONS-770
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-770
>             Project: Commons Collections
>          Issue Type: Bug
>    Affects Versions: 4.4
>            Reporter: Thomas Bürli
>            Priority: Minor
>         Attachments: SetUtilsTest.java, countHasNextCall.patch, stackdump.txt
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> I had the following code and my application stopped responsing as soon the number of names for a userId got too big.
> {code:java}
>        Map<String, Set<String>> stringMap = new TreeMap<>();
>         for (String name : names) {
>             for (String userId : userIds) {
>                 stringMap.merge(userId, Collections.singleton(name), SetUtils::union);
>             }
>         }
> {code}
> I did some debugging and it occurs when the toString method of one the set is called. It looks like the issues is with the iterator of "SetUtils.SetView".
> Here just the method I used to create test sets and in the attachment you find the full tests class and a stack dump. The execution time is growing exponentially with the numbers of times the SetUtils.union is called. So for 29 elements it took 16 seconds to execute toString, and with 30 it took 32 seconds.
> {code:java}
>     @Test
>     void setWith20Elements() {
>         assertTimeout(ofSeconds(2), () -> createSet(30).toString());
>     }
>     Set<String> createSet(int number) {
>         List<String> inputs = new ArrayList<>();
>         for (int i = 0; i < number; i++) {
>            inputs.add("Test"+ i);
>         }
>         Set<String> testSet = Collections.singleton("String1");
>         for (String element : inputs) {
>             Set<String> part = Collections.singleton(element);
>             testSet = SetUtils.union(testSet,part);
>         }
>         return testSet;
>     }
> {code}
> Thanks for your support



--
This message was sent by Atlassian Jira
(v8.20.7#820007)