Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2694

Tapestry PlasticClassPool & PropBinding & LiteralStringProvider make thousands of duplicate strings

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.7.3
    • 5.8.0
    • plastic
    • None

    Description

      I have completed a memory profile of our Tapestry application, and found that the PlasticClassPool & PropBinding have lots of duplicate Strings in memory.

      PropBinding

      Seems that both the `toString` and `expression` constructor parameters of PropBinding should be interned in the constructor.

      PlasticClassPool

      After some investigation, it seems that the `InheritanceData#getValue()` method is the likely culprit.

      Example Strings:

      "toString)"
      "get:(Ljava/lang/Object"
      "getPropertyName)"

      The current method:

          /**
           * Combines a method name and its desc (which describes parameter types and return value) to form
           * a value, which is how methods are tracked.
           */
          private static String toValue(String name, String desc)
          {
              // TAP5-2268: ignore return-type to avoid methods with the same number (and type) of parameters but different
              //            return-types which is illegal in Java.
              // desc is something like "(I)Ljava/lang/String;", which means: takes an int, returns a String. We strip
              // everything after the parameter list.
              int endOfParameterSpecIdx = desc.indexOf(')');
      
              return name + ":" + desc.substring(0, endOfParameterSpecIdx+1);
          }
      

      The change is simple one-liner to the return statement:

      return (name + ":" + desc.substring(0, endOfParameterSpecIdx+1)).intern();
      

      PageElementFactoryImpl$LiteralStringProvider

      The constructor for LiteralStringProvider should intern the string.

      Also, Duplicate InheritanceData

      The profile also showed that there are lots of "duplicate" InheritanceData objects... the interning will help with their size, but why have so many duplicate?

      Attachments

        1. Screen Shot 2021-09-29 at 4.02.26 PM.png
          325 kB
          Nikkie Folts
        2. Screen Shot 2021-09-29 at 4.03.04 PM.png
          299 kB
          Nikkie Folts
        3. Screen Shot 2021-09-29 at 5.23.53 PM.png
          462 kB
          Nikkie Folts
        4. Screen Shot 2021-09-30 at 4.58.19 PM.png
          285 kB
          Nikkie Folts
        5. Screen Shot 2021-10-04 at 2.07.35 PM.png
          301 kB
          Nikkie Folts

        Activity

          People

            thiagohp Thiago Henrique De Paula Figueiredo
            billapepper Nikkie Folts
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: