<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Hi Olivier,</p>
    <p>Thanks for reporting the problem and sharing your benchmarking
      results. It's good to see that you can apply Leyden on such big
      projects and see substantial start-up benefits.<br>
    </p>
    <p>We already have a bug opened for this issue:</p>
    <p><a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8342283">https://bugs.openjdk.org/browse/JDK-8342283</a></p>
    <p>I opened a PR a while back but got side tracked and the PR got
      closed:</p>
    <p><a class="moz-txt-link-freetext" href="https://github.com/openjdk/jdk/pull/21797">https://github.com/openjdk/jdk/pull/21797</a><br>
    </p>
    <p>Could you try applying this PR and see if it works for your test
      case?</p>
    <p>I will revive the PR and hopefully be able to fix it in JDK 25,
      where the bug is currently targeted to.</p>
    <p>Thanks</p>
    <p>- Ioi<br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 4/16/25 1:56 AM, Olivier Bourgain
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAP+OV9rOVsX5rmAhq1tPwi1c6bzzNN1SdEYshG95AO6pMR8AaA@mail.gmail.com">
      
      <div dir="ltr">
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt" id="gmail-docs-internal-guid-331337be-7fff-70e6-42d2-2e5d8af2ec03"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">Hello,</span></font></p>
        <font size="2"><span style="font-family:arial,sans-serif"><br>
          </span></font>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">I have been experimenting with Leyden for a pretty large Spring Boot application (>1M loc, fat jar is about 240MB) and I think I hit a limitation of the current implementation of  Leyden.</span></font></p>
        <font size="2"><span style="font-family:arial,sans-serif"><br>
          </span></font>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">I got the following error message at the end of the training run:</span></font></p>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">[31,832s][error  ][cds,heap   ] [ 0] {0x000000060080be70} jdk.internal.loader.ArchivedClassLoaders::appLoader (offset = 16)</span></font></p>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">[31,832s][error  ][cds,heap   ] [ 1] {0x0000000601400000} jdk.internal.loader.ClassLoaders$AppClassLoader::parallelLockMap (offset = 36)</span></font></p>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">[31,832s][error  ][cds,heap   ] [ 2] {0x000000060095c5a8} java.util.concurrent.ConcurrentHashMap</span></font></p>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">[31,832s][error  ][cds,heap   ] Cannot archive the sub-graph referenced from [Ljava.util.concurrent.ConcurrentHashMap$Node; object (0x000000060354bc88) size 262160, skipped.</span></font></p>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">[31,832s][error  ][cds    </span><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif"><span class="gmail-Apple-tab-span" style="white-space:pre">   </span></span><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">] An error has occurred while writing the shared archive file.</span></font></p>
        <font size="2"><span style="font-family:arial,sans-serif"><br>
          </span></font>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">So it looks like some classloader has a very large ConcurrentHashMap that ends up with a backing array of length 65536.</span></font></p>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">Tracing back to Leyden’s sources, I found that the the archived objects size is limited</span></font></p>
        <ul style="margin-top:0px;margin-bottom:0px">
          <li dir="ltr" style="list-style-type:disc;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt" role="presentation"><font size="2"><a href="https://github.com/openjdk/leyden/blob/master/src/hotspot/share/cds/heapShared.cpp#L295" style="text-decoration:none;font-family:arial,sans-serif" moz-do-not-send="true"><span style="color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">https://github.com/openjdk/leyden/blob/master/src/hotspot/share/cds/heapShared.cpp#L295</span></a></font></p></li>
          <li dir="ltr" style="list-style-type:disc;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt" role="presentation"><font size="2"><a href="https://github.com/openjdk/leyden/blob/master/src/hotspot/share/cds/archiveHeapWriter.cpp#L121" style="text-decoration:none;font-family:arial,sans-serif" moz-do-not-send="true"><span style="color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">https://github.com/openjdk/leyden/blob/master/src/hotspot/share/cds/archiveHeapWriter.cpp#L118</span></a></font></p></li>
          <li dir="ltr" style="list-style-type:disc;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt" role="presentation"><font size="2"><a href="https://github.com/openjdk/leyden/blob/83c7d3bbe860656ee403fa29df6a9e0aae962839/src/hotspot/share/cds/archiveHeapWriter.hpp#L118" style="text-decoration:none;font-family:arial,sans-serif" moz-do-not-send="true"><span style="color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">https://github.com/openjdk/leyden/blob/83c7d3bbe860656ee403fa29df6a9e0aae962839/src/hotspot/share/cds/archiveHeapWriter.hpp#L118</span></a></font></p></li>
        </ul>
        <font size="2"><span style="font-family:arial,sans-serif"><br>
            <br>
          </span></font>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">By adding a --add-opens java.base/java.util=ALL-UNNAMED to the command line, it disables the optimized module handling</span></font></p>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">[0.001s][info][cds] optimized module handling: disabled due to incompatible property: jdk.module.addopens=java.base/java.util=ALL-UNNAMED</span></font></p>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">And the error goes away.</span></font></p>
        <font size="2"><span style="font-family:arial,sans-serif"><br>
          </span></font>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">I tried to make my case work without adding some add-opens that are not required by the app. As the limit in object size comes from MIN_GC_REGION_ALIGNMENT, which is limited by Shenandoah’s region size, and I don’t use that GC, I simply modified is_too_large_to_archive() to always return false. Then the archiving with optimized module handling succeeds.</span></font></p>
        <font size="2"><span style="font-family:arial,sans-serif"><br>
          </span></font>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">I created a Github repo to reproduce the issue, see the readme there: </span><a href="https://github.com/obourgain/leyden-classloader" style="text-decoration:none;font-family:arial,sans-serif" moz-do-not-send="true"><span style="color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">https://github.com/obourgain/leyden-classloader</span></a></font></p>
        <font size="2"><span style="font-family:arial,sans-serif"><br>
          </span></font>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">With regard to the improvements in startup time (</span></font><font size="2">on a M1 mac)</font><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">, here is what is get:</span></font></p>
        <ul style="margin-top:0px;margin-bottom:0px">
          <li dir="ltr" style="list-style-type:disc;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt" role="presentation"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">base line, exploded Spring Boot jar = 11s</span></font></p></li>
          <li dir="ltr" style="list-style-type:disc;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt" role="presentation"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">spring AOT = 10.5s</span></font></p></li>
          <li dir="ltr" style="list-style-type:disc;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt" role="presentation"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">leyden with optimized module handling disabled = 7.8s </span></font></p></li>
          <li dir="ltr" style="list-style-type:disc;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt" role="presentation"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">leyden with optimized module handling enabled = 7.1s</span></font></p></li>
          <li dir="ltr" style="list-style-type:disc;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt" role="presentation"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">leyden with optimized module handling disabled and Spring AOT = 7.3s</span></font></p></li>
          <li dir="ltr" style="list-style-type:disc;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt" role="presentation"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">leyden with optimized module handling enabled and Spring AOT = 6.3s</span></font></p></li>
        </ul>
        <div><font size="2"><span style="font-family:arial,sans-serif"><br>
            </span></font></div>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">Overall, I think that’s pretty impressive improvements for this app’s startup which was pretty efficient already. Moreover, I did that on a project that started 12 or 13 years ago, so it shows that Leyden is applicable for that kind of project with substantial gains.</span></font></p>
        <div><br>
        </div>
        <div>I plan to try the premain branch soon.</div>
        <div><br>
        </div>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">Let me know if I can help with more information.</span></font></p>
        <font size="2"><span style="font-family:arial,sans-serif"><br>
          </span></font>
        <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;font-family:arial,sans-serif">(this message was first submitted before I subscribed to the list. A copy of it may be pending review by the admin. Feel free to delete the pending copy)</span></font></p>
        <font size="2"><span style="font-family:arial,sans-serif"><br>
          </span></font></div>
    </blockquote>
  </body>
</html>