<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <font size="4"><font face="monospace">BTW, I have found the
        AdaptNull/SHARED_3 benchmark to extremely useful for detecting
        *overall* regressions/improvements.  (Obviously targeted
        benchmarks are more useful for targeted problems like this one,
        but if people are going to run one bench before and after a
        change, it should be this one.)</font></font><br>
    <br>
    <div class="moz-cite-prefix">On 4/26/2023 11:12 AM, Adam Sotona
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CY4PR1001MB2150F60EE1294AB310C91C518C659@CY4PR1001MB2150.namprd10.prod.outlook.com">
      
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}div.WordSection1
        {page:WordSection1;}</style>
      <div class="WordSection1">
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US">FYI: Here is draft of pull request with initial
            batch of performance improvements (no API change):<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US"><a href="https://github.com/openjdk/jdk/pull/13671" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/openjdk/jdk/pull/13671</a><o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US">It is branched from PR13478 due to its
            significant changes in StackMapGenerator.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US">Here are some first measurable improvements:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas;mso-fareast-language:EN-US" lang="EN-US">Benchmark                     Mode  Cnt      
            Score       Error  Units<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas;mso-fareast-language:EN-US" lang="EN-US">GenerateStackMaps.benchmark  thrpt   10 
            407931.202 ± 13101.023  ops/s<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US">improved by approx 15% to:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas;mso-fareast-language:EN-US" lang="EN-US">GenerateStackMaps.benchmark  thrpt   10 
            470826.720 ±  3569.194  ops/s<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas;mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas;mso-fareast-language:EN-US" lang="EN-US">Adam<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
        <div style="border:none;border-top:solid #B5C4DF
          1.0pt;padding:3.0pt 0cm 0cm 0cm">
          <p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
              </span></b><span style="font-size:12.0pt;color:black">classfile-api-dev
              <a class="moz-txt-link-rfc2396E" href="mailto:classfile-api-dev-retn@openjdk.org"><classfile-api-dev-retn@openjdk.org></a> on behalf of
              Adam Sotona <a class="moz-txt-link-rfc2396E" href="mailto:adam.sotona@oracle.com"><adam.sotona@oracle.com></a><br>
              <b>Date: </b>Tuesday, 25 April 2023 16:25<br>
              <b>To: </b>Brian Goetz <a class="moz-txt-link-rfc2396E" href="mailto:brian.goetz@oracle.com"><brian.goetz@oracle.com></a>,
              <a class="moz-txt-link-abbreviated" href="mailto:liangchenblue@gmail.com">liangchenblue@gmail.com</a> <a class="moz-txt-link-rfc2396E" href="mailto:liangchenblue@gmail.com"><liangchenblue@gmail.com></a>,
              classfile-api-dev <a class="moz-txt-link-rfc2396E" href="mailto:classfile-api-dev@openjdk.org"><classfile-api-dev@openjdk.org></a><br>
              <b>Subject: </b>Re: Caching symbolic descriptors for the
              constant pool<o:p></o:p></span></p>
        </div>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US">I think it perfectly fits to the performance
            improvements I’m working on.</span><o:p></o:p></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US">The “caching” here means to 1:1 store symbol
            with PoolEntry after the first request or when the entry has
            been created from the symbol.</span><o:p></o:p></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US">There is no risk of any growing global caches.</span><o:p></o:p></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US"> </span><o:p></o:p></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US">If the Constants API will also “cache” internal
            class name in ClassDesc and ClassDescs of the MethodTypeDesc
            parameters and return type.
          </span><o:p></o:p></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US"> </span><o:p></o:p></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US">Then we can achieve paths with minimal or no
            conversions, for example:</span><o:p></o:p></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US" lang="EN-US">ClassDesc -> MethodTypeDesc ->
            CodeBuilder -> PoolEntry -> InvokeInstruction ->
            StackMapGenerator -> ClassHierarchyResolver ->
            ClassDesc -> internal class name ->
            StackMapGenerator.Type -> PoolEntry -> BufWriterImpl
            -> internal class name</span><o:p></o:p></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"> </span><o:p></o:p></p>
        <div style="border:none;border-top:solid #B5C4DF
          1.0pt;padding:3.0pt 0cm 0cm 0cm">
          <p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
              </span></b><span style="font-size:12.0pt;color:black">classfile-api-dev
              <a class="moz-txt-link-rfc2396E" href="mailto:classfile-api-dev-retn@openjdk.org"><classfile-api-dev-retn@openjdk.org></a> on behalf of
              Brian Goetz <a class="moz-txt-link-rfc2396E" href="mailto:brian.goetz@oracle.com"><brian.goetz@oracle.com></a><br>
              <b>Date: </b>Tuesday, 25 April 2023 16:12<br>
              <b>To: </b><a class="moz-txt-link-abbreviated" href="mailto:liangchenblue@gmail.com">liangchenblue@gmail.com</a>
              <a class="moz-txt-link-rfc2396E" href="mailto:liangchenblue@gmail.com"><liangchenblue@gmail.com></a>, classfile-api-dev
              <a class="moz-txt-link-rfc2396E" href="mailto:classfile-api-dev@openjdk.org"><classfile-api-dev@openjdk.org></a><br>
              <b>Subject: </b>Re: Caching symbolic descriptors for the
              constant pool</span><o:p></o:p></p>
        </div>
        <div>
          <p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">For caching symbols in the Class
              API, this is fine but we should wait a
              <br>
              bit.  Doing caching raises the question of where the cache
              lives and how <br>
              long it lives; we had some discussions recently about
              caching for class <br>
              hierarchy info, and concluded that we had reached the
              limits of what we <br>
              can do with static entry points.  By refactoring the main
              entry points <br>
              (build/parse) to instance methods on a user-controlled
              "classfile <br>
              context" object, we create a logical place and lifetime
              for caches, of <br>
              which we now have two examples.<br>
              <br>
              Adam currently has a queue of patches he is trying to
              shepherd in, after <br>
              which we will look at refactoring the CHA functionality,
              after which we <br>
              will look at refactoring the "front door", and then that
              should leave a <br>
              natural place to slot in caching of symbolic constants.<br>
              <br>
              On 4/24/2023 7:18 PM, - wrote:<br>
              > First, thanks for the feedback on my cache proposal a
              few days ago!<br>
              > I've prepared two patches under 8306697<br>
              > <a href="https://github.com/openjdk/jdk/pull/13598and" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/openjdk/jdk/pull/13598and</a>
              8306698<br>
              > <a href="https://github.com/openjdk/jdk/pull/13599" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/openjdk/jdk/pull/13599</a>,
              which will hopefully make<br>
              > the Constant API more useful with classfiles.<br>
              ><br>
              > I wish to cache symbolic descriptors in classfile API
              itself. One of<br>
              > the prime candidates identified by Adam in his
              migration of<br>
              > java.lang.invoke to classfile API is
              ClassEntry.asSymbol, which from<br>
              > my search, appears to be frequently used in stack map
              generation. In<br>
              > addition, a MethodTypeDesc is passed to stack map
              generator<br>
              > constructor via ofDescriptor (which has slow parsing
              even after Adam's<br>
              > optimization), but the parsing can totally be averted
              if we can reuse<br>
              > the MethodTypeDesc passed in withMethod(). Thus, I
              wish to add<br>
              > accessors like typeSymbol() and cachedTypeSymbol()
              for MethodInfo to<br>
              > speed up StackMapGenerator initialization.<br>
              ><br>
              > In addition, the stack map generator has a custom
              bitset-based tool to<br>
              > split a descriptor on the fly (See<br>
              > StackMapGenerator.processInvokeInstructions). I
              believe they can<br>
              > benefit from reusing a parsed MethodTypeDesc as well,
              especially if<br>
              > the invoke instructions were originally built with
              MethodTypeDesc.<br>
              ><br>
              > Chen Liang</span><o:p></o:p></p>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>