[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-serviceability-dev
Subject: Re: RFR : JDK-8154166 - java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
From: Jaroslav Bachorik <j.bachorik () gmail ! com>
Date: 2016-04-29 8:45:51
Message-ID: CAJBAviusjk+CTkiODxCsuuM_30qeomcuUsu5ViNBvBdVR7RGiQ () mail ! gmail ! com
[Download RAW message or body]
On Fri, Apr 29, 2016 at 6:20 AM, Harsha Wardhana B <
harsha.wardhana.b@oracle.com> wrote:
> Hi Jaroslav,
>
> I am not sure how @required tag works. I searched code base and it is not
> used in any file. Also, the documentation on Jtreg page is sparse.
>
> Could you paste an example as to how to use it?
>
Please, take a look
at jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java -
actually, it is '@requires' tag.
>
> Also, I would still think that repeated gc via weak-reference is right and
> defensive approach. So I would like to leave that in place unless it is
> causing any side-effects.
>
No objections here. It does not break anything and makes the test
intentions clearer.
-JB-
>
> Thanks
> Harsha
>
>
> On Tuesday 26 April 2016 04:05 PM, Jaroslav Bachorik wrote:
>
>
>
> On Mon, Apr 25, 2016 at 9:27 AM, Harsha Wardhana B <
> <harsha.wardhana.b@oracle.com>harsha.wardhana.b@oracle.com> wrote:
>
>> Hi,
>>
>> Please review below patch to disable concurrent GC option.
>> http://cr.openjdk.java.net/~hb/8154166/webrev.01/
>>
>
> I'm sorry to be a PITA, but why it is not possible to use the @require tag?
>
>
>>
>>
>> Jaroslav,
>>
>> According to Javadoc of Runtime.gc(),
>>
>> https://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#gc--
>>
>> The call will only make it's best effort to do a GC and provides no
>> guarantee that a given object can be collected even if GC runs.
>> It does not say that Runtime.gc() call will block till entire GC cycle is
>> finished and hence we cannot be making that assumption.
>>
>
> I know, I had the same discussion a while ago when fixing some other tests
> failing when run with allowed concurrent explicit GC and I was pointed to
> the fact that all the known implementation actually do wait until the
> complete GC cycle is over before returning. Otherwise all those tests
> relying on some memory having been reclaimed or some counters having been
> increased would have to be considered random.
>
>
>>
>> Hence it is required that we encapsulate the target object in
>> WeakReference and repeatedly call GC till weakRef returns null.
>> Granted that we will have a small window when weakRef returns null and
>> the target object is not removed from memory. But I see no way how to fix
>> that problem.
>>
>
> Exactly. The only guarantee for all the GC related metrics having been
> updated before proceeding with the test is being able to run the explicit
> GC in blocking manner. Otherwise the tests are not really deterministic and
> can intermittently fail.
>
> -JB-
>
>
>>
>> -Harsha
>>
>>
>> On Sunday 24 April 2016 03:17 PM, Jaroslav Bachorik wrote:
>>
>> The reproducer would be very time sensitive as with the provided
>> 'ExplicitGCInvokesConcurrent' it will run GC concurrently with the invoker.
>> Otherwise, in the current implementation, calling Runtime.gc() would
>> guarantee the GC cycle has finished before that method returns.
>>
>> The WeakReference javadoc (
>> <https://docs.oracle.com/javase/7/docs/api/java/lang/ref/WeakReference.html>
>> https://docs.oracle.com/javase/7/docs/api/java/lang/ref/WeakReference.html)
>> is only stating that the referenced object will be made finalizable at the
>> same time as the reference is cleared. As a consequence a cleared reference
>> might not always mean that the heap usage has been changed (unless a
>> particular GC implementation makes some additional guarantees).
>>
>> I know we were stabilizing a bunch of related tests relying on GC doing
>> its work before checking for some post-conditions and the only way to make
>> the tests reliable was to forbid running those tests with
>> '-XX:+ExplicitGCInvokesConcurrent'.
>>
>> -JB-
>>
>> On Sat, Apr 23, 2016 at 12:15 PM, Harsha Wardhana B <
>> <harsha.wardhana.b@oracle.com>harsha.wardhana.b@oracle.com> wrote:
>>
>>> Hello,
>>>
>>> The issue was not reproducible with or without,
>>>
>>> "-XX:+ExplicitGCInvokesConcurrent"
>>>
>>> Flag. The patch ensures that GC happens before we start measuring
>>> memory. Without the patch, GC might or might not happen.
>>>
>>> -Harsha
>>>
>>>
>>> On Friday 22 April 2016 07:58 PM, Jaroslav Bachorik wrote:
>>>
>>> Hi,
>>>
>>> On Fri, Apr 22, 2016 at 9:10 AM, Harsha Wardhana B <
>>> <harsha.wardhana.b@oracle.com>harsha.wardhana.b@oracle.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Please review the below simple fix for issue,
>>>>
>>>> issue : <https://bugs.openjdk.java.net/browse/JDK-8154166>
>>>> https://bugs.openjdk.java.net/browse/JDK-8154166
>>>> webrev : <http://cr.openjdk.java.net/%7Ehb/8154166/webrev.00/>
>>>> http://cr.openjdk.java.net/~hb/8154166/webrev.00/
>>>>
>>>
>>> Shouldn't this test rather declare the conditions when it is supposed to
>>> work? According to the issue this was caused by introducing the "-XX:+ExplicitGCInvokesConcurrent"
>>> which makes it very tricky to make any assumptions about the GC process.
>>>
>>> See eg. jdk/tests/java/lang/management/MemoryMXBean/LowMemoryTest.java
>>> for enabling the test only for allowed configurations.
>>>
>>> Cheers,
>>>
>>> -JB-
>>>
>>>
>>>>
>>>>
>>>> -Harsha
>>>>
>>>>
>>>
>>>
>>
>>
>
>
[Attachment #3 (text/html)]
<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr \
29, 2016 at 6:20 AM, Harsha Wardhana B <span dir="ltr"><<a \
href="mailto:harsha.wardhana.b@oracle.com" \
target="_blank">harsha.wardhana.b@oracle.com</a>></span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>
Hi Jaroslav,<br>
<br>
I am not sure how @required tag works. I searched code base and it
is not used in any file. Also, the documentation on Jtreg page is
sparse. <br>
<br>
Could you paste an example as to how to use \
it?<br></div></blockquote><div><br></div><div>Please, take a look at \
jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java - actually, it is \
'@requires' tag.</div><div> </div><blockquote class="gmail_quote" \
style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>
<br>
Also, I would still think that repeated gc via weak-reference is
right and defensive approach. So I would like to leave that in place
unless it is causing any \
side-effects.<br></div></blockquote><div><br></div><div>No objections here. It does \
not break anything and makes the test intentions \
clearer.</div><div><br></div><div>-JB-</div><div> </div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>
<br>
Thanks<span class=""><font color="#888888"><br>
Harsha</font></span><div><div class="h5"><br>
<br>
<div>On Tuesday 26 April 2016 04:05 PM,
Jaroslav Bachorik wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Apr 25, 2016 at 9:27 AM,
Harsha Wardhana B <span dir="ltr"><<a \
href="mailto:harsha.wardhana.b@oracle.com" target="_blank"></a><a \
href="mailto:harsha.wardhana.b@oracle.com" \
target="_blank">harsha.wardhana.b@oracle.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Hi,<br>
<br>
Please review below patch to disable concurrent GC
option.<br>
<a href="http://cr.openjdk.java.net/%7Ehb/8154166/webrev.01/" \
target="_blank">http://cr.openjdk.java.net/~hb/8154166/webrev.01/</a></div> \
</blockquote> <div><br>
</div>
<div>I'm sorry to be a PITA, but why it is not possible to
use the @require tag?</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><br>
<br>
Jaroslav,<br>
<br>
According to Javadoc of Runtime.gc(),<br>
<br>
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#gc" \
target="_blank">https://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#gc</a>--<br>
<br>
The call will only make it's best effort to do a GC and
provides no guarantee that a given object can be
collected even if GC runs. <br>
It does not say that Runtime.gc() call will block till
entire GC cycle is finished and hence we cannot be
making that assumption. <br>
</div>
</blockquote>
<div><br>
</div>
<div>I know, I had the same discussion a while ago when
fixing some other tests failing when run with allowed
concurrent explicit GC and I was pointed to the fact that
all the known implementation actually do wait until the
complete GC cycle is over before returning. Otherwise all
those tests relying on some memory having been reclaimed
or some counters having been increased would have to be
considered random.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> <br>
Hence it is required that we encapsulate the target
object in WeakReference and repeatedly call GC till
weakRef returns null.<br>
Granted that we will have a small window when weakRef
returns null and the target object is not removed from
memory. But I see no way how to fix that problem. <br>
</div>
</blockquote>
<div><br>
</div>
<div>Exactly. The only guarantee for all the GC related
metrics having been updated before proceeding with the
test is being able to run the explicit GC in blocking
manner. Otherwise the tests are not really deterministic
and can intermittently fail.</div>
<div><br>
</div>
<div>-JB-</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><span><font color="#888888"> <br>
-Harsha</font></span>
<div>
<div><br>
<br>
<div>On Sunday 24 April 2016 03:17 PM, Jaroslav
Bachorik wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">The reproducer would be very time
sensitive as with the provided
'ExplicitGCInvokesConcurrent' it will run GC
concurrently with the invoker. Otherwise, in the
current implementation, calling Runtime.gc()
would guarantee the GC cycle has finished before
that method returns.
<div><br>
</div>
<div>The WeakReference javadoc (<a \
href="https://docs.oracle.com/javase/7/docs/api/java/lang/ref/WeakReference.html" \
target="_blank"></a><a \
href="https://docs.oracle.com/javase/7/docs/api/java/lang/ref/WeakReference.html" \
target="_blank">https://docs.oracle.com/javase/7/docs/api/java/lang/ref/WeakReference.html</a>)
is only stating that the referenced object
will be made finalizable at the same time as
the reference is cleared. As a consequence a
cleared reference might not always mean that
the heap usage has been changed (unless a
particular GC implementation makes some
additional guarantees).<br>
<br>
I know we were stabilizing a bunch of related
tests relying on GC doing its work before
checking for some post-conditions and the only
way to make the tests reliable was to forbid
running those tests with
'-XX:+ExplicitGCInvokesConcurrent'.</div>
<div><br>
</div>
<div>-JB-</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Sat, Apr 23, 2016 at
12:15 PM, Harsha Wardhana B <span dir="ltr"><<a \
href="mailto:harsha.wardhana.b@oracle.com" target="_blank"></a><a \
href="mailto:harsha.wardhana.b@oracle.com" \
target="_blank">harsha.wardhana.b@oracle.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
The issue was not reproducible with or
without, <br>
<br>
"<span \
style="color:rgb(51,51,51);font-family:sans-serif;font-size:14px;line-height:20px">-XX:+ExplicitGCInvokesConcurrent"<br>
</span><br>
<div>Flag. The patch ensures that GC
happens before we start measuring
memory. Without the patch, GC might or
might not happen.<span><font color="#888888"><br>
<br>
-Harsha</font></span>
<div>
<div><br>
<br>
On Friday 22 April 2016 07:58 PM,
Jaroslav Bachorik wrote:<br>
</div>
</div>
</div>
<div>
<div>
<blockquote type="cite">
<div dir="ltr">Hi,
<div><br>
</div>
<div class="gmail_extra">
<div class="gmail_quote">On Fri,
Apr 22, 2016 at 9:10 AM,
Harsha Wardhana B <span dir="ltr"><<a \
href="mailto:harsha.wardhana.b@oracle.com" target="_blank"></a><a \
href="mailto:harsha.wardhana.b@oracle.com" \
target="_blank">harsha.wardhana.b@oracle.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" \
style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> \
Hi,<br> <br>
Please review the below
simple fix for issue,<br>
<br>
issue : <a \
href="https://bugs.openjdk.java.net/browse/JDK-8154166" target="_blank"></a><a \
href="https://bugs.openjdk.java.net/browse/JDK-8154166" \
target="_blank">https://bugs.openjdk.java.net/browse/JDK-8154166</a> <br>
webrev : <a \
href="http://cr.openjdk.java.net/%7Ehb/8154166/webrev.00/" target="_blank"></a><a \
href="http://cr.openjdk.java.net/~hb/8154166/webrev.00/" \
target="_blank">http://cr.openjdk.java.net/~hb/8154166/webrev.00/</a></div> \
</blockquote> <div><br>
</div>
<div>Shouldn't this test
rather declare the
conditions when it is
supposed to work? According
to the issue this was caused
by introducing the "<span \
style="color:rgb(51,51,51);font-family:sans-serif;font-size:14px;line-height:20px">-XX:+ExplicitGCInvokesConcurrent"
which makes it very tricky
to make any assumptions
about the GC process.</span></div>
<div><br>
</div>
<div>See eg.
\
jdk/tests/java/lang/management/MemoryMXBean/LowMemoryTest.java for enabling the test \
only
for allowed configurations.<br>
<br>
Cheers,</div>
<div><br>
</div>
<div>-JB-</div>
<div> </div>
<blockquote class="gmail_quote" \
style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" \
text="#000000"><span><font color="#888888"><br> <br>
-Harsha<br>
<br>
</font></span></div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
</div></div></div>
</blockquote></div><br></div></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic