<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 7/8/24 9:04 AM, Charles Oliver
      Nutter wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAE-f1xRn_Lh0=zRp5=fO0ek=xoV2iqNzyagTAD9nG43JuXaz=Q@mail.gmail.com">
      
      <div dir="ltr">The patched build does indeed work, and cuts
        JRuby's base startup time by 50%! Bravo!
        <div><br>
        </div>
        <div>$ time jruby -e 1<br>
          jruby -e 1  3.53s user 0.14s system 276% cpu 1.326 total<br>
          $ time jruby -J-XX:CacheDataStore=jruby.cds -e 1<br>
          jruby -J-XX:CacheDataStore=jruby.cds -e 1  2.38s user 0.19s
          system 385% cpu 0.667 total<br>
        </div>
        <div><br>
        </div>
        <div>This is a very promising start and the largest single
          improvement we have seen. Comparison with our previous
          champion, C1:</div>
        <div><br>
        </div>
        <div>$ time jruby --dev -e 1<br>
          jruby --dev -e 1  1.22s user 0.09s system 142% cpu 0.922 total<br>
        </div>
        <div><br>
        </div>
        <div>Interestingly, when I try to use the previously trained CDS
          dump (via 100.times { org.jruby.Ruby.newInstance }) with a
          command line that forces C1 (--dev flag passes
          -XX:TieredStopAtLevel=1) I get a different crash: <a href="https://urldefense.com/v3/__https://gist.github.com/headius/d3138efa52eed9c678414c8cfe08af27__;!!ACWV5N9M2RV99hQ!O1UAeB7nD1zEm6bMPw7oDGNPEmvkkh6jK5YVmZJVKQP6Ugi5tSURjYzIpMvg0XmXhF6oaTom1wRsn5A$" moz-do-not-send="true">https://gist.github.com/headius/d3138efa52eed9c678414c8cfe08af27</a></div>
        <div><br>
        </div>
      </div>
    </blockquote>
    <p>I filed <a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8336033">https://bugs.openjdk.org/browse/JDK-8336033</a> . It looks
      like a simple book keeping issue in the compiler code.<br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite" cite="mid:CAE-f1xRn_Lh0=zRp5=fO0ek=xoV2iqNzyagTAD9nG43JuXaz=Q@mail.gmail.com">
      <div dir="ltr">
        <div>I'm wondering what else I can do to try to train the CDS
          dump better, so that a larger command (jruby -S gem list) sees
          more improvement (this loads a bunch more Ruby code into the
          interpreter):</div>
        <div><br>
        </div>
        <div>$ time jruby -S gem list > /dev/null<br>
          jruby -S gem list > /dev/null  6.41s user 0.26s system 236%
          cpu 2.821 total<br>
          $ time jruby -J-XX:CacheDataStore=jruby.cds -S gem list >
          /dev/null<br>
          jruby -J-XX:CacheDataStore=jruby.cds -S gem list >
          /dev/null  5.84s user 0.32s system 294% cpu 2.089 total<br>
        </div>
        <div><br>
        </div>
      </div>
    </blockquote>
    <br>
    Does this load a lot of dynamically generated classes? The current
    set of Leyden optimizations are mostly for classes loaded in the
    built-in loaders (boot/platform/app).<br>
    <p>I wonder how much of the time is spend in one-time activity. If
      you run the above inside a loop (2x, 4x, 8x, 16x, etc), how does
      it scale?</p>
    <p>I think if we see a big drop between 1x vs 2x, then perhaps the
      current set of Leyden optimizations can help (as long as most of
      the time is spent in the built-in loaders).</p>
    <p>In any case, dynamic language runtimes like jruby probably have
      very different start-up characteristics than, say, your typical
      "micro service" Java app. More analysis is needed.</p>
    <p>Thanks</p>
    <p>- Ioi<br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite" cite="mid:CAE-f1xRn_Lh0=zRp5=fO0ek=xoV2iqNzyagTAD9nG43JuXaz=Q@mail.gmail.com">
      <div dir="ltr">
        <div>- Charlie</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Thu, Jul 4, 2024 at
          11:50 PM <<a href="mailto:ioi.lam@oracle.com" moz-do-not-send="true" class="moz-txt-link-freetext">ioi.lam@oracle.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div> <font face="monospace">Hi Charlie,<br>
              <br>
              Thanks for the bug report.<br>
              <br>
              It turns out some Leyden optimizations can't handle the
              module options specified by jruby, such as these:<br>
              <br>
                  --add-opens=java.base/java.nio.channels=org.jruby.dist<br>
                  --module-path=/xxxx/jruby-9.4.8.0/lib/jruby.jar<br>
              <br>
              I filed <a href="https://bugs.openjdk.org/browse/JDK-8335735" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">https://bugs.openjdk.org/browse/JDK-8335735</a><br>
              <br>
              I'll work on a proper fix. Meanwhile, I have a work-around
              in this branch<br>
              <br>
                 
              <a href="https://urldefense.com/v3/__https://github.com/iklam/jdk/tree/work-around-8335735-jruby-crash-due-to-lack-of-module-support__;!!ACWV5N9M2RV99hQ!O1UAeB7nD1zEm6bMPw7oDGNPEmvkkh6jK5YVmZJVKQP6Ugi5tSURjYzIpMvg0XmXhF6oaTomY2MJITU$" target="_blank" moz-do-not-send="true">https://github.com/iklam/jdk/tree/work-around-8335735-jruby-crash-due-to-lack-of-module-support</a><br>
              <br>
              If you build a JDK from this source branch, you can see
              the following improvements:<br>
              <br>
              # [1] No optimizations<br>
              $ time env JAVA_HOME=$MYJAVA
              ~/Downloads/ruby/jruby-9.4.8.0/bin/jruby \<br>
                  -e '10.times { org.jruby.Ruby.newInstance }'<br>
              real   0m3.215s<br>
              user   0m14.868s<br>
              sys    0m0.373s<br>
              <br>
              <br>
              # [2] Leyden<br>
              $ time env JAVA_HOME=$TBP0
              ~/Downloads/ruby/jruby-9.4.8.0/bin/jruby \<br>
                  -J-XX:CacheDataStore=jruby.cds \<br>
                  -e '10.times { org.jruby.Ruby.newInstance }'<br>
              real   0m1.880s<br>
              user   0m9.001s<br>
              sys    0m0.268s<br>
              <br>
              <br>
            </font><font face="monospace"># [3] Compare with CDS in the
              JDK mainline<br>
              $ env JAVA_HOME=$MYJAVA
              ~/Downloads/ruby/jruby-9.4.8.0/bin/jruby \<br>
                   -J-XX:DumpLoadedClassList=jruby.classlist \<br>
                   -e '10.times { org.jruby.Ruby.newInstance }'<br>
              $ $MYJAVA/bin/java -Xshare:dump \<br>
                 
              --module-path=/home/iklam/Downloads/ruby/jruby-9.4.8.0/lib/jruby.jar
              \<br>
                  -XX:SharedClassListFile=jruby.classlist \<br>
                  -XX:SharedArchiveFile=jruby.jsa -Xlog:cds<br>
              $ time env JAVA_HOME=$MYJAVA
              ~/Downloads/ruby/jruby-9.4.8.0/bin/jruby \<br>
                  -J-XX:SharedArchiveFile=jruby.jsa \<br>
                  -e '10.times { org.jruby.Ruby.newInstance }'<br>
              real   0m2.628s<br>
              user   0m13.007s<br>
              sys    0m0.428s<br>
              <br>
              Please try it out and let us know if you run into other
              problems.<br>
              <br>
              Thanks<br>
              <br>
              - Ioi</font><font face="monospace"><span style="color:rgb(23,43,77);font-size:14px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;white-space:normal;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
              </span></font><font face="monospace"><span style="color:rgb(23,43,77);font-size:14px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;white-space:normal;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"></span></font><br>
            <font face="monospace"><br>
            </font>
            <div><font face="monospace">On 7/4/24 1:06 PM, Charles
                Oliver Nutter wrote:<br>
              </font></div>
            <blockquote type="cite">
              <div dir="ltr"><font face="monospace">Hello friends! Long
                  time lurker, first time poster.</font>
                <div><font face="monospace"><br>
                  </font></div>
                <div><font face="monospace">Like others I was excited to
                    hear that the first EA of Leyden had dropped. Sadly,
                    I have another crash to report.</font></div>
                <div><font face="monospace"><br>
                  </font></div>
                <div><font face="monospace">I see there are two other
                    crashes reported, but mine appears different
                    (ClassPrelinker::is_indy_resolution_deterministic):</font></div>
                <div><font face="monospace"><br>
                  </font></div>
                <div><font face="monospace"><a href="https://urldefense.com/v3/__https://gist.github.com/headius/79c6460ed55c1d80c82e1c0209897e24__;!!ACWV5N9M2RV99hQ!O1UAeB7nD1zEm6bMPw7oDGNPEmvkkh6jK5YVmZJVKQP6Ugi5tSURjYzIpMvg0XmXhF6oaTomO4igb9c$" target="_blank" moz-do-not-send="true">https://gist.github.com/headius/79c6460ed55c1d80c82e1c0209897e24</a><br>
                  </font></div>
                <div><font face="monospace"><br>
                  </font></div>
                <div><font face="monospace">Perhaps unsurprisingly, the
                    additional flags provided by Vladimir Kozlov (<span style="color:rgb(0,0,0)">-XX:+UnlockDiagnosticVMOptions
                      -XX:-ReduceAllocationMerges) did not appear to
                      change the result.</span></font></div>
                <div><font face="monospace"><span style="color:rgb(0,0,0)"><br>
                    </span></font></div>
                <div><font face="monospace"><span style="color:rgb(0,0,0)">This is with JRuby's
                      minimally invokedynamic-based mode, which has
                      given us the shortest startup time in the past
                      (second only to disabling tiers 2-4 and staying in
                      C1).</span></font></div>
                <div><font face="monospace"><span style="color:rgb(0,0,0)"><br>
                    </span></font></div>
                <div><font face="monospace" color="#000000">I am on
                    MacOS AArch64 Sonoma 14.5, testing against JRuby
                    master, but reproduction should be as easy as
                    downloading the JRuby binary tarball, unpacking, and
                    running bin/jruby with the command line above.</font></div>
                <div><font face="monospace" color="#000000"><br>
                  </font></div>
                <div><font face="monospace"><a href="https://urldefense.com/v3/__https://www.jruby.org/download__;!!ACWV5N9M2RV99hQ!O1UAeB7nD1zEm6bMPw7oDGNPEmvkkh6jK5YVmZJVKQP6Ugi5tSURjYzIpMvg0XmXhF6oaTom4BSxN20$" target="_blank" moz-do-not-send="true">https://www.jruby.org/download</a><font color="#000000"><br>
                    </font></font></div>
                <div><font face="monospace"><span style="color:rgb(0,0,0)"><br>
                    </span></font></div>
                <div><font face="monospace"><span style="color:rgb(0,0,0)">I am eager to work with
                      Leyden folks to investigate issues, and I am
                      planning to be at JVMLS this year to discuss
                      collaborating more!</span></font></div>
                <div><font face="monospace"><span style="color:rgb(0,0,0)"><br>
                    </span></font></div>
                <div><font face="monospace"><span style="color:rgb(0,0,0)">- Charlie</span></font></div>
              </div>
            </blockquote>
          </div>
        </blockquote>
      </div>
    </blockquote>
  </body>
</html>