MyFaces Trinidad
  1. MyFaces Trinidad
  2. TRINIDAD-1275

Optimize org.apache.myfaces.trinidadinternal.share.url.EncoderUtilsto use less CPU time

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.10-core
    • Component/s: None
    • Labels:
      None

      Description

      While looking at some test cases we noticed that EncoderUtils::_writeURL uses a lot of CPU to do its work. The basic problem is that frequent calls to charAt and calls to underlying writer to write just char or int can be very expensive.
      The overall optimization idea is:
      1. Instead of doing charAt do toCharArray once. This will use a little bit more of transient memory but it will be faster
      2. Instead of doing frequent writes to the writer create one StringBuilder and work on it. Once _writeURL is done with all the transformations do the finale write(string) to the underlying writer

      In our test case we had 4200 calls to _writeURL which used 2356ms of CPU time. With the optimizations the same number of calls uses 268ms. This is almost 9x improvement

      Attached is the patch for the changes

      1. EncodeUtils.patch
        10 kB
        Stevan Malesevic

        Activity

        Stevan Malesevic created issue -
        Hide
        Stevan Malesevic added a comment -

        Prototype patch

        Show
        Stevan Malesevic added a comment - Prototype patch
        Stevan Malesevic made changes -
        Field Original Value New Value
        Attachment EncodeUtils.patch [ 12392575 ]
        Matthias Weßendorf made changes -
        Fix Version/s 1.2.10-core [ 12313342 ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Matthias Weßendorf [ matzew ]
        Matthias Weßendorf made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Matthias Weßendorf
            Reporter:
            Stevan Malesevic
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development