You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2020/07/06 08:27:00 UTC

[jira] [Commented] (WICKET-6800) Use LinkedHashSet instead of LinkedList for AjaxRequestHandler#listeners

    [ https://issues.apache.org/jira/browse/WICKET-6800?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17151871#comment-17151871 ] 

ASF subversion and git services commented on WICKET-6800:
---------------------------------------------------------

Commit 1b41c78dd7c7dd9eb153ec408f56d9029416fed2 in wicket's branch refs/heads/wicket-8.x from Urs Joss
[ https://gitbox.apache.org/repos/asf?p=wicket.git;h=1b41c78 ]

WICKET-6800 AjaxRequestHandler: Keep listeners in a LinkedHashSet instead of LinkedList for performance reason (#438)

(cherry picked from commit 5c63eb59510d954f52150f069690a528849cd803)


> Use LinkedHashSet instead of LinkedList for AjaxRequestHandler#listeners
> ------------------------------------------------------------------------
>
>                 Key: WICKET-6800
>                 URL: https://issues.apache.org/jira/browse/WICKET-6800
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 8.8.0, 9.0.0-M6
>            Reporter: Martin Tzvetanov Grigorov
>            Assignee: Martin Tzvetanov Grigorov
>            Priority: Minor
>
> https://github.com/apache/wicket/pull/438
> Urs Joss:
> While migrating my project (see PR there) from the mocking library mockito to mock, I ran into weird performance issues. The build time jumped from roughly 20 minutes to eventually more than 4 hours. I took some effort improving various things in my own code (less mocking, more memory etc.) but did not bring it down considerably until I addressed a bottleneck I found in wicket.
> AjaxRequestHandler maintains a collection of listeners in a LinkedList. When client code adds a new listener calling method addListener, it uses the collection's method contains to assert we don't add a listener to the collection twice. This doesn't scale well. For some reason, my setup with mockk seems to add many more listeners than what my code did with mockito, so I ran into this issue with continuously slower test executions.
> I managed to temporarily resolve the problem in my project by plugging in my own copy of AjaxRequestHandler where I swapped the collection type from LinkedList to LinkedHashSet (calling setAjaxRequestTargetProvider in my TestApplication). With this approach the total build time went down again to 20-30 minutes.
> This PR serves the purpose of starting a discussion about whether this change would be feasible to implement in wicket directly. To me, it is not apparent why a LinkedList had been chosen initially. The LinkedHashSet performs much better with contains and still preserves insertion order. If that latter should turn out to be not relevant, we could even consider using a HashSet instead of a linked HashSet, but I presume insertion order is important.
> A separate topic on my side will be to figure out why my setup with mockito seemed to work well while migrating to mockk surfaced this issue.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)