Re: [rvm-research] Disable VM shutdown/GC in the end of VM execution
Kenan Liu <[email protected]> Mon, 3 Dec 2018 15:11:05 -0800
| Newsgroups | gmane.comp.java.jikes.rvm.devel |
|---|---|
| Message-ID | <CA+qhk+ry1RNyf2MDKqNhJ+4zjZ4CsyuPo6QkCNeone+dLfMYdw@mail.gmail.com> |
--===============6905235105945536792== Content-Type: multipart/alternative; boundary="00000000000014a467057c2644a4" --00000000000014a467057c2644a4 Content-Type: text/plain; charset="UTF-8" Hi Erik and Robin, Thank you for your well explained emails. The problem was resolved with Erik suggestion using shutdown hook. I just can't find time to say thank you:) I haven't tried ExitMonitor. I did read the paper about compiler replay. It could also be the solution for my problem with another direction. For shutdown with destroying the current container. That's the issue but should not be the JikesRVM bug since the program should've been finished by that time from JikesRVM point of view. The shutdown hook which was suggested by Erik is the perfect solution since shutdown hook is the part of VM behavior which is used in JikesRVM. It can hold all system exit methods to wait until the hook method finishes. Thank you! Kenan On Wed, Nov 14, 2018 at 3:20 PM Robin Garner <[email protected]> wrote: > Hi Kenan, > > Did you try using one of Jikes RVM's ExitMonitor callbacks (not that > they should be significantly different to the standard Java shutdown > hook) ? These are successfully used by a number of things such as > compiler profiling for replay. > > Even during shutdown, MMTk's collectors shouldn't be destroying live > data - the root set and/or heap traversal mechanisms don't change during > shutdown. Is the data structure you're using a collection of POJOs, or > something trickier ? Is the data structure being corrupted or is your > thread being terminated before it can complete ? > > cheers > > On 13/11/18 6:00 am, Kenan Liu wrote: > > Hi Erik, > > > > Thank you for your reply. > > > > We haven't tried Java API to shutdown VM because don't want to > > interrupt the current Jikes RVM behavior. We are trying to figure out > > the shutdown point that Jikes RVM normally executes instead of shut > > down by exception or error signal. > > > > We tried inserted our profiling collection in the > > org.jikesrvm.VM.shutdown() and org.jikesrvm.VM.sysExit() before the > > shutdown() method. In both situations the data only can be partially > > printed out. It looks like the collection would be destroyed before it > > finishes. > > > > *Case 1 (in shutdown()):* > > > > @Uninterruptible public static void shutdown(int value) { > > VM.disableGC();** > > > > LogQueue.dumpWithRawData(Service.clsNameList, > > Service.methodNameList); VM.enableGC();** > > > > handlePossibleRecursiveShutdown(); > > > > > > > > if (VM.VerifyAssertions) VM._assert(VM.runningVM); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > sysCall.sysExit(value); > > > > if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED); > > > > } > > > > *Case 2 (in sysExit()):* > > > > @NoInline > > > > @UninterruptibleNoWarn("We're never returning to the caller, so > even > > though this code is preemptible it is safe to call from any context") > > > > public static void sysExit(int value) { > > > > handlePossibleRecursiveCallToSysExit(); > > > > > > > > if (VM.countThreadTransitions) { > > > > RVMThread.reportThreadTransitionCounts(); > > > > } > > > > > > > > if (Options.stackTraceAtExit) { > > > > VM.sysWriteln("[Here is the context of the call to VM.sysExit(", > > value, ")...:"); > > > > VM.disableGC(); > > > > RVMThread.dumpStack(); > > > > VM.enableGC(); > > > > VM.sysWriteln("... END context of the call to VM.sysExit]"); > > > > } > > > > if (runningVM) { > > > > VM.disableGC(); > > > > LogQueue.dumpLogQueue(Service.clsNameList, Service.methodNameList); > > > > VM.enableGC(); > > > > Callbacks.notifyExit(value); > > > > VM.shutdown(value); > > > > } else { > > > > System.exit(value); > > > > } > > > > if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED); > > > > } > > > > > > > > I read the Oracle article about the Design of Shutdown Hooks API > > < > https://docs.oracle.com/javase/8/docs/technotes/guides/lang/hook-design.html>. > > > It looks like the shutdown hooks are usually run concurrently. Is that > > the case in Jikes RVM? > > > > Given this case, what can we do to get all data printed out before the > > collection is destroyed in the meantime the program has been finished? > > > > Thanks, > > Kenan > > > > On Fri, Nov 9, 2018 at 1:33 PM Erik Brangs <[email protected] > > <mailto:[email protected]>> wrote: > > > > Hi, > > > > On 09.11.2018 18:01, Kenan Liu wrote: > > > Is there any way that we can let VM wait until our printout > > finishes before it shuts down? We have been stuck here for a > > while. Thank you for any helps you could provide. > > > > Have you tried using shutdown hooks from the normal Java API? > > > > Jikes RVM currently doesn't run shutdown hooks when it's > > terminated via a signal but they should work for other cases. > > > > > > Kind regards, > > > > Erik Brangs > > > > > > _______________________________________________ > > Jikesrvm-researchers mailing list > > [email protected] > > <mailto:[email protected]> > > https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers > > > > > > > > -- > > Kenan Liu > > PhD Candidate in Computer Science > > SUNY Binghamton > > > > > > _______________________________________________ > > Jikesrvm-researchers mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers > > > _______________________________________________ > Jikesrvm-researchers mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers > -- Kenan Liu PhD Candidate in Computer Science SUNY Binghamton --00000000000014a467057c2644a4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Hi Erik and Robin,</div><div><br></div><div>Thank you= for your well explained emails.=C2=A0</div><div><br></div><div>The problem= was resolved with Erik suggestion using shutdown hook. I just can't fi= nd time to say thank you:)</div><div><br></div><div>I haven't tried Exi= tMonitor. I did read the paper about compiler replay. It could also be the = solution for my problem with another direction. For shutdown with destroyin= g the current container. That's the issue but should not be the JikesRV= M bug since the program should've been finished by that time from Jikes= RVM point of=C2=A0view. The shutdown hook which was suggested by Erik is th= e perfect solution since shutdown hook is the part of VM behavior which is = used in JikesRVM. It can hold all system exit methods to wait until the hoo= k method finishes.</div><div><br></div><div>Thank you!</div><div>Kenan</div= ></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Wed, Nov 14, 2018= at 3:20 PM Robin Garner <<a href=3D"mailto:[email protected]">robi= [email protected]</a>> wrote:<br></div><blockquote class=3D"gmail_quote= " style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">H= i Kenan,<br> <br> Did you try using one of Jikes RVM's ExitMonitor callbacks (not that <b= r> they should be significantly different to the standard Java shutdown <br> hook) ?=C2=A0 These are successfully used by a number of things such as <br= > compiler profiling for replay.<br> <br> Even during shutdown, MMTk's collectors shouldn't be destroying liv= e <br> data - the root set and/or heap traversal mechanisms don't change durin= g <br> shutdown.=C2=A0 Is the data structure you're using a collection of POJO= s, or <br> something trickier ?=C2=A0 Is the data structure being corrupted or is your= <br> thread being terminated before it can complete ?<br> <br> cheers<br> <br> On 13/11/18 6:00 am, Kenan Liu wrote:<br> > Hi Erik,<br> ><br> > Thank you for=C2=A0your=C2=A0reply.<br> ><br> > We haven't tried Java API to shutdown VM because don't want to= <br> > interrupt the current Jikes RVM behavior. We are trying to figure out = <br> > the shutdown point that Jikes RVM normally executes instead of shut <b= r> > down by exception or error signal.<br> ><br> > We tried inserted our profiling collection in the <br> > org.jikesrvm.VM.shutdown() and org.jikesrvm.VM.sysExit() before the <b= r> > shutdown() method. In both situations the data only can be partially <= br> > printed out. It looks like the collection would be destroyed before it= <br> > finishes.<br> ><br> > *Case 1 (in shutdown()):*<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0@Uninterruptible public static void shutdown= (int value) { <br> > VM.disableGC();**<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0LogQueue.dumpWithRawData(Service.clsNameList= , <br> > Service.methodNameList); VM.enableGC();**<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 handlePossibleRecursiveSh= utdown();<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0if (VM.VerifyAssertions) VM._assert(VM.runni= ngVM);<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 sysCall.sysExit(value);<b= r> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0if (VM.VerifyAssertions) VM._assert(VM.NOT_R= EACHED);<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 }<br> ><br> > *Case 2 (in sysExit()):*<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0@NoInline<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0@UninterruptibleNoWarn("We're never= returning to the caller, so even <br> > though this code is preemptible it is safe to call from any context&qu= ot;)<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0public static void sysExit(int value) {<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 handlePossibleRecursiveCa= llToSysExit();<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0if (VM.countThreadTransitions) {<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0RVMThread.reportThreadTransitionCounts();<br= > ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 }<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0if (Options.stackTraceAtExit) {<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0VM.sysWriteln("[Here is the context of = the call to VM.sysExit(", <br> > value, ")...:");<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0VM.disableGC();<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0RVMThread.dumpStack();<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0VM.enableGC();<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0VM.sysWriteln("... END context of the c= all to VM.sysExit]");<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 }<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0if (runningVM) {<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0VM.disableGC();<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0LogQueue.dumpLogQueue(Service.clsNameList, S= ervice.methodNameList);<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0VM.enableGC();<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0Callbacks.notifyExit(value);<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0VM.shutdown(value);<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 } else {<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0System.exit(value);<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 }<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0if (VM.VerifyAssertions) VM._assert(VM.NOT_R= EACHED);<br> ><br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 }<br> ><br> ><br> ><br> > I read the Oracle article about the Design of Shutdown Hooks API <br> > <<a href=3D"https://docs.oracle.com/javase/8/docs/technotes/guides/= lang/hook-design.html" rel=3D"noreferrer" target=3D"_blank">https://docs.or= acle.com/javase/8/docs/technotes/guides/lang/hook-design.html</a>>. <br> > It looks like the shutdown hooks are usually run concurrently. Is that= <br> > the case in Jikes RVM?<br> ><br> > Given this case, what can we do to get all data printed out before the= <br> > collection is destroyed in the meantime the program has been finished?= <br> ><br> > Thanks,<br> > Kenan<br> ><br> > On Fri, Nov 9, 2018 at 1:33 PM Erik Brangs <<a href=3D"mailto:erik.= [email protected]" target=3D"_blank">[email protected]</a> <br> > <mailto:<a href=3D"mailto:[email protected]" target=3D"_blank">eri= [email protected]</a>>> wrote:<br> ><br> >=C2=A0 =C2=A0 =C2=A0Hi,<br> ><br> >=C2=A0 =C2=A0 =C2=A0On 09.11.2018 18:01, Kenan Liu wrote:<br> >=C2=A0 =C2=A0 =C2=A0> Is there any way that we can let VM wait until= our printout<br> >=C2=A0 =C2=A0 =C2=A0finishes before it shuts down? We have been stuck h= ere for a<br> >=C2=A0 =C2=A0 =C2=A0while. Thank you for any helps you could provide.<b= r> ><br> >=C2=A0 =C2=A0 =C2=A0Have you tried using shutdown hooks from the normal= Java API?<br> ><br> >=C2=A0 =C2=A0 =C2=A0Jikes RVM currently doesn't run shutdown hooks = when it's<br> >=C2=A0 =C2=A0 =C2=A0terminated via a signal but they should work for ot= her cases.<br> ><br> ><br> >=C2=A0 =C2=A0 =C2=A0Kind regards,<br> ><br> >=C2=A0 =C2=A0 =C2=A0Erik Brangs<br> ><br> ><br> >=C2=A0 =C2=A0 =C2=A0_______________________________________________<br> >=C2=A0 =C2=A0 =C2=A0Jikesrvm-researchers mailing list<br> >=C2=A0 =C2=A0 =C2=A0<a href=3D"mailto:[email protected]= forge.net" target=3D"_blank">[email protected]</a>= <br> >=C2=A0 =C2=A0 =C2=A0<mailto:<a href=3D"mailto:Jikesrvm-researchers@l= ists.sourceforge.net" target=3D"_blank">[email protected]= rge.net</a>><br> >=C2=A0 =C2=A0 =C2=A0<a href=3D"https://lists.sourceforge.net/lists/list= info/jikesrvm-researchers" rel=3D"noreferrer" target=3D"_blank">https://lis= ts.sourceforge.net/lists/listinfo/jikesrvm-researchers</a><br> ><br> ><br> ><br> > -- <br> > Kenan Liu<br> > PhD Candidate in Computer Science<br> > SUNY Binghamton<br> ><br> ><br> > _______________________________________________<br> > Jikesrvm-researchers mailing list<br> > <a href=3D"mailto:[email protected]" target= =3D"_blank">[email protected]</a><br> > <a href=3D"https://lists.sourceforge.net/lists/listinfo/jikesrvm-resea= rchers" rel=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/= lists/listinfo/jikesrvm-researchers</a><br> <br> <br> _______________________________________________<br> Jikesrvm-researchers mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_bl= ank">[email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/jikesrvm-researcher= s" rel=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/lists= /listinfo/jikesrvm-researchers</a><br> </blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g= mail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div><d= iv>Kenan Liu<br></div>PhD Candidate in Computer Science<br></div>SUNY Bingh= amton<br></div></div> --00000000000014a467057c2644a4-- --===============6905235105945536792== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============6905235105945536792== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Jikesrvm-researchers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers --===============6905235105945536792==--