I don't understand the wording here.
Hello Leyden Dev Team, I was reading the Leyden doc Brian Goetz put out this month called "Condensing Indy Bootstraps". https://openjdk.org/projects/leyden/notes/04-condensing-bootstraps Here is a quote from the last sentence of the first paragraph.
However, the bootstraps used by javac generally avoid runtime dependencies the most dynamic features of method handles, and therefore are likely candidates for such re-shifting.
I don't understand the wording here. Mistype? Thank you for your time and help! David Alayachew
From: "David Alayachew" <davidalayachew@gmail.com> To: "leyden-dev" <leyden-dev@openjdk.org> Sent: Sunday, August 27, 2023 8:34:22 PM Subject: I don't understand the wording here.
Hello Leyden Dev Team,
Hello David,
I was reading the Leyden doc Brian Goetz put out this month called "Condensing Indy Bootstraps".
[ https://openjdk.org/projects/leyden/notes/04-condensing-bootstraps | https://openjdk.org/projects/leyden/notes/04-condensing-bootstraps ]
Here is a quote from the last sentence of the first paragraph.
However, the bootstraps used by javac generally avoid runtime dependencies the most dynamic features of method handles, and therefore are likely candidates for such re-shifting.
I don't understand the wording here. Mistype?
I will explain what it means. Invokedynamic calls a bootstrap method that returns a CallSite. There are two kind of callsites, ConstantCallSite and MutableCallSite, a constant callsite means that the callsite can be optimized now while a mutable callsite means the callsite can be optimized later, once the target is stable enough. Currently, javac generates invokedynamic that only uses constant callsites. Since this doc was created, we now know that the distiller phase [1] is more prowerful than previously thought so we may not need to condense indy bootstrap methods but just annotate them to say if the result needed to be replayed or not. So the same mechanism can be used for both static fields and bootstrap methods. If you play with the premain prototype of Leyden [2], there is a global option -XX:+ArchiveInvokeDynamic that stores all the callsite targets of the first run (training run) inside the CDS archive. Here is an example of how to use the prototype to run maven [3], the first run of maven keep the dynamic information into a CDS archive and a code archive so the next runs re-use those informations to get a faster warmup time.
Thank you for your time and help! David Alayachew
[1] [ https://openjdk.org/projects/leyden/notes/03-toward-condensers | https://openjdk.org/projects/leyden/notes/03-toward-condensers ] [2] [ https://github.com/openjdk/leyden/tree/premain | https://github.com/openjdk/leyden/tree/premain ] [3] [ https://github.com/forax/computed-constant/blob/master/mvn-leyden.bash | https://github.com/forax/computed-constant/blob/master/mvn-leyden.bash ]
Hello Rémi, Thank you for your response! What you have described makes a lot of sense, and the document is much easier to understand as a result. Is there any chance that we could replace that quoted text? Maybe the document is out of date, but I'm pretty sure the quoted text is not even valid english, let alone a passage whose meaning can be easily extracted. Thank you for your time and help! David Alayachew On Sun, Aug 27, 2023 at 4:24 PM Remi Forax <forax@univ-mlv.fr> wrote:
------------------------------
*From: *"David Alayachew" <davidalayachew@gmail.com> *To: *"leyden-dev" <leyden-dev@openjdk.org> *Sent: *Sunday, August 27, 2023 8:34:22 PM *Subject: *I don't understand the wording here.
Hello Leyden Dev Team,
Hello David,
I was reading the Leyden doc Brian Goetz put out this month called "Condensing Indy Bootstraps".
https://openjdk.org/projects/leyden/notes/04-condensing-bootstraps
Here is a quote from the last sentence of the first paragraph.
However, the bootstraps used by javac generally avoid runtime dependencies the most dynamic features of method handles, and therefore are likely candidates for such re-shifting.
I don't understand the wording here. Mistype?
I will explain what it means. Invokedynamic calls a bootstrap method that returns a CallSite. There are two kind of callsites, ConstantCallSite and MutableCallSite, a constant callsite means that the callsite can be optimized now while a mutable callsite means the callsite can be optimized later, once the target is stable enough. Currently, javac generates invokedynamic that only uses constant callsites.
Since this doc was created, we now know that the distiller phase [1] is more prowerful than previously thought so we may not need to condense indy bootstrap methods but just annotate them to say if the result needed to be replayed or not. So the same mechanism can be used for both static fields and bootstrap methods.
If you play with the premain prototype of Leyden [2], there is a global option -XX:+ArchiveInvokeDynamic that stores all the callsite targets of the first run (training run) inside the CDS archive. Here is an example of how to use the prototype to run maven [3], the first run of maven keep the dynamic information into a CDS archive and a code archive so the next runs re-use those informations to get a faster warmup time.
Thank you for your time and help! David Alayachew
[1] https://openjdk.org/projects/leyden/notes/03-toward-condensers [2] https://github.com/openjdk/leyden/tree/premain [3] https://github.com/forax/computed-constant/blob/master/mvn-leyden.bash
On 8/27/2023 1:24 PM, Remi Forax wrote:
If you play with the premain prototype of Leyden [2], there is a global option -XX:+ArchiveInvokeDynamic that stores all the callsite targets of the first run (training run) inside the CDS archive. Here is an example of how to use the prototype to run maven [3], the first run of maven keep the dynamic information into a CDS archive and a code archive so the next runs re-use those informations to get a faster warmup time.
[1] https://openjdk.org/projects/leyden/notes/03-toward-condensers [2] https://github.com/openjdk/leyden/tree/premain [3] https://github.com/forax/computed-constant/blob/master/mvn-leyden.bash
Hi Remi, Thanks for trying the premain prototype. It's in very rough shape so it will probably cause many surprises ... One thing I want to point out is that the -XX:+ArchiveInvokeDynamic option works only with "static CDS dump", e.g., -Xshare:dump. It has no effect with "dynamic CDS dump", e.g., the -XX:ArchiveClassesAtExit option used by your script in [3] above. I have some docs about using the -XX:+ArchiveInvokeDynamic flag and checking its effects: https://github.com/openjdk/leyden/blob/premain/test/hotspot/jtreg/premain/In... You can also see some stats like: $ java -Xshare:dump -Xlog:cds -XX:+ArchiveInvokeDynamic [...] [4.209s][info ][cds ] Class CP entries = 19623, archived = 6600 ( 33.6%) [4.209s][info ][cds ] Field CP entries = 7867, archived = 2481 ( 31.5%) [4.209s][info ][cds ] Method CP entries = 32366, archived = 3354 ( 10.4%) [4.209s][info ][cds ] Indy CP entries = 729, archived = 56 ( 7.7%) Thanks - Ioi
From: "Ioi Lam" <ioi.lam@oracle.com> To: "leyden-dev" <leyden-dev@openjdk.org> Sent: Monday, August 28, 2023 11:12:56 PM Subject: Re: I don't understand the wording here.
On 8/27/2023 1:24 PM, Remi Forax wrote:
If you play with the premain prototype of Leyden [2], there is a global option -XX:+ArchiveInvokeDynamic that stores all the callsite targets of the first run (training run) inside the CDS archive. Here is an example of how to use the prototype to run maven [3], the first run of maven keep the dynamic information into a CDS archive and a code archive so the next runs re-use those informations to get a faster warmup time.
[1] [ https://openjdk.org/projects/leyden/notes/03-toward-condensers | https://openjdk.org/projects/leyden/notes/03-toward-condensers ] [2] [ https://github.com/openjdk/leyden/tree/premain | https://github.com/openjdk/leyden/tree/premain ] [3] [ https://github.com/forax/computed-constant/blob/master/mvn-leyden.bash | https://github.com/forax/computed-constant/blob/master/mvn-leyden.bash ]
Hi Remi,
Thanks for trying the premain prototype. It's in very rough shape so it will probably cause many surprises ... Not a lot, my main issue was having a training too short so a lot a compiled methods were not reaching the state 4.
One thing I want to point out is that the -XX:+ArchiveInvokeDynamic option works only with "static CDS dump", e.g., -Xshare:dump.
It has no effect with "dynamic CDS dump", e.g., the -XX:ArchiveClassesAtExit option used by your script in [3] above. Ahh, thanks for the info, My first version had the 3 passes, static CDS -> dynamic CDS -> replay, but I wrongly supposed that using 2 passes, dynamic CDS -> replay was possible and I did not checked if the Indy CP rentries were stored in the dynamic CDS.
I have some docs about using the -XX:+ArchiveInvokeDynamic flag and checking its effects:
[ https://github.com/openjdk/leyden/blob/premain/test/hotspot/jtreg/premain/In... | https://github.com/openjdk/leyden/blob/premain/test/hotspot/jtreg/premain/In... ]
Interresting, (BTW, The link to the prelinker is broken, it is in "src" not "test").
You can also see some stats like:
$ java -Xshare:dump -Xlog:cds -XX:+ArchiveInvokeDynamic [...] [4.209s][info ][cds ] Class CP entries = 19623, archived = 6600 ( 33.6%) [4.209s][info ][cds ] Field CP entries = 7867, archived = 2481 ( 31.5%) [4.209s][info ][cds ] Method CP entries = 32366, archived = 3354 ( 10.4%) [4.209s][info ][cds ] Indy CP entries = 729, archived = 56 ( 7.7%)
Thanks - Ioi
Regards, Rémi
participants (3)
-
David Alayachew
-
Ioi Lam
-
Remi Forax