<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body><div style="font-family: sans-serif;"><div class="markdown" style="white-space: normal;">
<p dir="auto">On 8 Jun 2023, at 9:52, Dan Heidinga wrote:</p>
</div><div class="plaintext" style="white-space: normal;"><blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; color: #777777;"><p dir="auto">On Thu, Jun 8, 2023 at 12:44 PM John Rose <john.r.rose@oracle.com> wrote:</p>
<blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; border-left-color: #999999; color: #999999;"><p dir="auto">On 8 Jun 2023, at 9:01, Dan Heidinga wrote:</p>
<blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; border-left-color: #BBBBBB; color: #BBBBBB;"><p dir="auto">If we decouple the list of preloadable classes from the classfile, how
<br>
would non-jdk classes be handled?> What if instead of ditching the</p>
</blockquote><p dir="auto">attribute, or treating it like an</p>
<blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; border-left-color: #BBBBBB; color: #BBBBBB;"><p dir="auto">optimization, we firmed up the contract and treated it as a guarantee…</p>
</blockquote><p dir="auto">If we go down this route, let’s consider putting the control information
<br>
into a module file (only) for starters.  (Maybe class file later if
<br>
needed.)  There would be fewer states to document and test, since (by
<br>
definition) class files could not get out of sync.</p>
<p dir="auto">A module would document, in one mplace, which types it would “prefer” to
<br>
preload in order to optimize its APIs (internal or external).</p>
</blockquote><p dir="auto">This might lead to more class loading than intended.  The current approach
<br>
has each classfile register the list of classes it wants preloaded to get
<br>
the best linkage which means we only have to load those classes if we link
<br>
the original class.  There's a natural trigger for the preload and a
<br>
limited set of classes to load.</p>
</blockquote></div>
<div class="markdown" style="white-space: normal;">
<p dir="auto">There’s a spectrum of tradeoffs here:  We could put preload attributes on every method and field, to get the maximum amount of fine-grained lazy (pre-)loading, or put them in a global file per JVM instance.  The more fine-grained, the harder it will be to write compliance testing, I think.</p>
</div><div class="plaintext" style="white-space: normal;"><blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; color: #777777;"><p dir="auto">Moving to a single per-module list loses the natural trigger and may
<br>
pre-load more classes than the application will use.  If Module A has
<br>
classes {A, B, C} and each one preloads 5 separate classes, with a
<br>
per-module list that's forcing the loading of 15 additional classes (plus
<br>
supers, etc).  With a per-class list, we only preload the classes on a
<br>
per-use basis.  More of a pay for what you use model.</p>
<p dir="auto">Is there a natural trigger or way to limit the preloads to what I might use
<br>
with the per-module file?</p>
</blockquote></div>
<div class="markdown" style="white-space: normal;">
<p dir="auto">That’s a very good question.  I think what Preload <em>really is</em> is a list of “names that may require special handling before using in APIs”.  They don’t need to be loaded when the preload attribute is parsed; they are simply put in a “watch list” to trigger additional loading <em>when necessary</em>.  (This is already true.)  So I think if we move the preload list to (say) the module level (if not a global file), then the JVM will have its watch list.  (And, in fewer chunks than if we put all the stuff all the time redundantly in all class files that might need them:  That requires frequent repetition.)  The JVM can use its watch list as it does today, with watch lists populated separately for each class file.</p>
<p dir="auto">To emphasize:  A watch list does not require loading.  It means, “if you see this name at a point where you could use extra class info, then I encourage you to load sooner rather than later”.  The only reason it is “a thing” at all is that the default behavior (of loading either as late as possible, or as part of a CDS-like thingy) should be changed only on an explicit signal.</p>
<p dir="auto">And, hey, maybe CDS is all the primitive we need here:  Just run -Xdump with all of your class path loaded.  Et voila, no Preload at all.</p>

</div></div></body>

</html>