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

jdk.nashorn.internal.runtime.Source.getContent() does excess Object.clone()

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u40
    • Fix Version/s: 9
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b29
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        Profiling a simple scenario:

        $ ~/Install/jdk9u20/bin/java -jar dist/nashorn.jar -Dnashorn.typeInfo.disabled=false --class-cache-size=0 --persistent-code-cache=false -scripting --log=time test/script/basic/compile-octane.js -- --iterations 5

        ...yields a few simple low-hanging fruits, here is one of them. Out of 220 seconds of run, ~5 seconds are spent here:

        6.160 jdk.nashorn.internal.parser.Parser.parse()
        6.160 jdk.nashorn.internal.parser.Parser.parse(java.lang.String, int, int, boolean)
        4.830 jdk.nashorn.internal.parser.Lexer.<init>(jdk.nashorn.internal.runtime.Source, int, int, jdk.nashorn.internal.parser.TokenStream, boolean)
        4.830 jdk.nashorn.internal.runtime.Source.getContent()
        4.820 java.lang.Object.clone()

        Sundar tells me that defensive copy is needed to shut FindBugs up, which means we could gain the performance back by sharing the original char[] via getContent()

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                sundar Sundararajan Athijegannathan
                Reporter:
                shade Aleksey Shipilev
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: