Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v5]

2022-01-25 Thread Aleksey Shipilev
On Tue, 25 Jan 2022 16:33:10 GMT, Aleksey Shipilev wrote: >> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two >> issues with it: >> - The cache cannot disambiguate between cleared SoftReference and the >> accidental passing of `null` value; in that case, the retry

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v5]

2022-01-25 Thread Roger Riggs
On Tue, 25 Jan 2022 16:33:10 GMT, Aleksey Shipilev wrote: >> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two >> issues with it: >> - The cache cannot disambiguate between cleared SoftReference and the >> accidental passing of `null` value; in that case, the retry

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v4]

2022-01-25 Thread Aleksey Shipilev
On Tue, 25 Jan 2022 16:12:11 GMT, Aleksey Shipilev wrote: > > This looks good, although I don't know whether the additional check for > > strongReferent != null is needed in clearStrong(). This is all racy code > > and you have already got a non-null return from getStrong() in case you are > >

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v5]

2022-01-25 Thread Aleksey Shipilev
> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two > issues with it: > - The cache cannot disambiguate between cleared SoftReference and the > accidental passing of `null` value; in that case, the retry loop would spin > indefinitely; > - If retry loop would spin

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache

2022-01-25 Thread Aleksey Shipilev
On Tue, 18 Jan 2022 20:07:10 GMT, Roger Riggs wrote: >> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two >> issues with it: >> - The cache cannot disambiguate between cleared SoftReference and the >> accidental passing of `null` value; in that case, the retry loop

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v4]

2022-01-25 Thread Aleksey Shipilev
On Mon, 24 Jan 2022 21:32:16 GMT, Peter Levart wrote: > This looks good, although I don't know whether the additional check for > strongReferent != null is needed in clearStrong(). This is all racy code and > you have already got a non-null return from getStrong() in case you are > calling cle

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v4]

2022-01-24 Thread Peter Levart
On Fri, 21 Jan 2022 11:04:22 GMT, Aleksey Shipilev wrote: >> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two >> issues with it: >> - The cache cannot disambiguate between cleared SoftReference and the >> accidental passing of `null` value; in that case, the retry

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v3]

2022-01-21 Thread Aleksey Shipilev
On Wed, 19 Jan 2022 13:10:55 GMT, Peter Levart wrote: > WDYT? I like the idea of holding to a value strongly for a brief period of time, in order to guarantee progress! The sample code was a bit hard to follow, so I rewrote the loop a bit with comments, see new commit. This still passes tests.

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v4]

2022-01-21 Thread Aleksey Shipilev
> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two > issues with it: > - The cache cannot disambiguate between cleared SoftReference and the > accidental passing of `null` value; in that case, the retry loop would spin > indefinitely; > - If retry loop would spin

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v3]

2022-01-19 Thread Peter Levart
On Wed, 19 Jan 2022 13:10:55 GMT, Peter Levart wrote: > Note this matches other places we do the weak-reference loops, for example in > `MethodType`: > https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/invoke/MethodType.java#L1390-L1401 This one does not have the

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v3]

2022-01-19 Thread Peter Levart
On Wed, 19 Jan 2022 10:44:57 GMT, Aleksey Shipilev wrote: > > So, this patch is fine for making ClassCache more robust as a re-usable > > component inside JDK (checking for non-null return of computeValue). The > > 2nd change, that apparently shields against unbounded accumulation of > > garba

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v3]

2022-01-19 Thread Peter Levart
On Wed, 19 Jan 2022 08:25:55 GMT, Aleksey Shipilev wrote: >> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two >> issues with it: >> - The cache cannot disambiguate between cleared SoftReference and the >> accidental passing of `null` value; in that case, the retry

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v3]

2022-01-19 Thread Aleksey Shipilev
On Wed, 19 Jan 2022 10:42:02 GMT, Peter Levart wrote: > So, this patch is fine for making ClassCache more robust as a re-usable > component inside JDK (checking for non-null return of computeValue). The 2nd > change, that apparently shields against unbounded accumulation of garbage, > might no

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v3]

2022-01-19 Thread Peter Levart
On Wed, 19 Jan 2022 08:25:55 GMT, Aleksey Shipilev wrote: >> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two >> issues with it: >> - The cache cannot disambiguate between cleared SoftReference and the >> accidental passing of `null` value; in that case, the retry

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v3]

2022-01-19 Thread Roman Kennke
On Wed, 19 Jan 2022 08:25:55 GMT, Aleksey Shipilev wrote: >> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two >> issues with it: >> - The cache cannot disambiguate between cleared SoftReference and the >> accidental passing of `null` value; in that case, the retry

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v3]

2022-01-19 Thread Aleksey Shipilev
> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two > issues with it: > - The cache cannot disambiguate between cleared SoftReference and the > accidental passing of `null` value; in that case, the retry loop would spin > indefinitely; > - If retry loop would spin

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache

2022-01-19 Thread Aleksey Shipilev
On Tue, 18 Jan 2022 20:07:10 GMT, Roger Riggs wrote: > It may not be worth it. If not, add the label "noreg-hard". Added. > It is possible for add to the test description the modules to be opened: > ``` > * @modules java.base/java.io:open > ``` > > jtreg will add the appropriate command line

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache [v2]

2022-01-19 Thread Aleksey Shipilev
> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two > issues with it: > - The cache cannot disambiguate between cleared SoftReference and the > accidental passing of `null` value; in that case, the retry loop would spin > indefinitely; > - If retry loop would spin

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache

2022-01-18 Thread Roger Riggs
On Fri, 14 Jan 2022 19:27:18 GMT, Aleksey Shipilev wrote: > JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two > issues with it: > - The cache cannot disambiguate between cleared SoftReference and the > accidental passing of `null` value; in that case, the retry loop

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache

2022-01-18 Thread Aleksey Shipilev
On Tue, 18 Jan 2022 18:22:26 GMT, Roger Riggs wrote: > Can a test be written to verify the correct handling of nulls. `java.io.ClassCache` is not public (for a reason), I struggle to find a way to access it from a jtreg test... - PR: https://git.openjdk.java.net/jdk/pull/7092

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache

2022-01-18 Thread Roger Riggs
On Fri, 14 Jan 2022 19:27:18 GMT, Aleksey Shipilev wrote: > JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two > issues with it: > - The cache cannot disambiguate between cleared SoftReference and the > accidental passing of `null` value; in that case, the retry loop

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache

2022-01-18 Thread Roman Kennke
On Fri, 14 Jan 2022 22:26:31 GMT, Aleksey Shipilev wrote: > > One additional improvement would be to change r.get() == null to > > r.refersTo(null) to check for cleared reference, that avoids reviving the > > referent, e.g. in SATB GCs. I leave that up to you. > > I think that does not work, b

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache

2022-01-18 Thread Roman Kennke
On Fri, 14 Jan 2022 19:27:18 GMT, Aleksey Shipilev wrote: > JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two > issues with it: > - The cache cannot disambiguate between cleared SoftReference and the > accidental passing of `null` value; in that case, the retry loop

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache

2022-01-14 Thread Aleksey Shipilev
On Fri, 14 Jan 2022 20:50:24 GMT, Roman Kennke wrote: > One additional improvement would be to change r.get() == null to > r.refersTo(null) to check for cleared reference, that avoids reviving the > referent, e.g. in SATB GCs. I leave that up to you. I think that does not work, because we want

Re: RFR: 8280041: Retry loop issues in java.io.ClassCache

2022-01-14 Thread Roman Kennke
On Fri, 14 Jan 2022 19:27:18 GMT, Aleksey Shipilev wrote: > JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two > issues with it: > - The cache cannot disambiguate between cleared SoftReference and the > accidental passing of `null` value; in that case, the retry loop