Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8160697

HTMLWriter needs perf cleanup

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • tools
    • b132
    • Not verified

      HTMLWriter contains 40 members which are "public final Content".

      Not only do these fields not belong on this class from an abstraction point of view (they would be somewhat better placed on HtmlDocWriter/HtmlDocletWriter) but more significantly, ALL these 3 classes get instantiated at least once per file generated, meaning that all those 40 members get instantiated once per file generated -- and yet they are all constants obtained from getResource, and in many cases will not even be used.

      This is probably one of the reasons why Configuration.getText was showing up in perf runs, and fixed in part by Claes in JDK-8157102.
      But while he made doclet resource lookup faster, we can significantly reduce the number of lookups, to once per resource, instead of once per resource per file.

      I also note while browsing code that while HtmlWriter proactively looks up some resources, I have come across cases where the value is ignored, and looked up again "as needed" in method bodies in various subtypes.

      These resources should all be obtained from a single object, available from the Configuration. There should either be an enum or named string constants to identify the resources, to avoid resource names in strings throughout the code (as is currently the case.)

      I also note that we need not do a conversion all at once; once we have the basic mechanism in place, we just need to audit/replace the calls to HtmlWriter.getResource and HtmlWriter.getNonBreakResource one at a time with calls to the new underlying mechanism.

            jjg Jonathan Gibbons
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: