Uploaded image for project: 'MyFaces Trinidad'
  1. MyFaces Trinidad
  2. TRINIDAD-1275

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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

        Attachments

        1. EncodeUtils.patch
          10 kB
          Stevan Malesevic

          Activity

            People

            • Assignee:
              matzew Matthias We├čendorf
              Reporter:
              smalesevic Stevan Malesevic
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: