<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">The order of the roles is not
      important. I think we should change the SimpleRole implementation
      in PicketBox to use Collection (HashSet) reference instead of List
      and then change any WildFly code that might be using the List
      reference.<br>
      <br>
      On 06/08/2015 03:25 AM, Philippe Marschall wrote:<br>
    </div>
    <blockquote cite="mid:55753557.9070409@gmx.net" type="cite">Hi
      <br>
      <br>
      I’m aware this may no technically be the right list to discuss
      this but this list is impacted by this and fairly active.
      <br>
      <br>
      During load testing of our application we found a case we spend
      10% of your CPU time in SimpleRole#equals (see attachment). This
      is because SimpleRoleGroup uses an ArrayList to maintain a unique
      set of roles. As a result it has to call ArrayList#contains a lot,
      which is itself O(n). In fact because that’s done when iterating
      over all the roles it becomes O(n^2). In our case our principals
      can have up to 200 roles. I don’t know if this is exceptionally
      many or a common case.
      <br>
      <br>
      We would like to work on a patch but we need your guidance. There
      are several possible solutions and it all comes down to whether we
      can change the List in the RoleGroup interface to a Collection.
      All the users we searched for in WildFly only used the return
      value for iterating over, nobody used the index. In fact they all
      used it an a for-each loop so the change would even be source
      compatible but unfortunately not binary compatible. If we can
      change the interface then we can just change the ArrayList in
      SimpleRoleGroup to a HashSet and be done with it. If the order is
      important the we can either use a TreeSet or a LinkedHashSet.
      <br>
      If changing the RoleGroup interface is not possible then there are
      two other possibilities. The first is only internally using a Set
      but in getRoles perform a copy. This would produce more garbage.
      The second option would be a having a Set and List (to avoid
      having to do copies) in SimpleRoleGroup. This would avoid having
      to do a copy and the Set can be used for contains checks. Only
      removeRole would still be O(n) due to the scan over ArrayList. The
      only user we found was OptionsRoleMappingProvider.
      <br>
      All of these would change the serialized form. If it is important
      to support reading old instances that could be added as well.
      <br>
      <br>
      Cheers
      <br>
      Philippe
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
wildfly-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:wildfly-dev@lists.jboss.org">wildfly-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/wildfly-dev">https://lists.jboss.org/mailman/listinfo/wildfly-dev</a></pre>
    </blockquote>
    <br>
  </body>
</html>