RFR: 7879: Automated Analysis taking very long time to produce results for Class Leak Rule and showing wrong results. [v4]

Suchita Chaturvedi schaturvedi at openjdk.org
Mon Oct 10 12:21:13 UTC 2022


On Fri, 7 Oct 2022 07:28:55 GMT, Brice Dutheil <bdutheil at openjdk.org> wrote:

>>> > @bric3 We need to show the names of top 5 classes which were loaded maximum times without being unloaded. So the ordering matters here. That's why I have skipped that comment.
>>> 
>>> I'm a bit confused, as in `DefaultIItemResultSet` the _insertion_ in `data` order is dependent on the iteration order of the aggregate collection, since it's a set, there's no ordering guarantees. Although I lack knowledge of the actual type and the implementation is a `TreeSet` or something alike.
>>> 
>>> https://github.com/openjdk/jmc/blob/1696e03a1fddb9cc68d32bf21a281ef24366e552/core/org.openjdk.jmc.flightrecorder.rules.jdk/src/main/java/org/openjdk/jmc/flightrecorder/rules/jdk/util/DefaultIItemResultSet.java#L95-L99
>>> 
>>> Moreover the usage of the thread pool here will not guarantee the `add` operation will happen in the same order as the tasks have been submitted. Which leads me to think that the code should be reworked here to ensure that the results will be inserted in order.
>> 
>> I have used a synchronized block for data. After that I am getting consistent results. Without that I was getting different results every time. I mean when I was working for test JFR wldf.jfr without synchronized block on data, the top 5 results varied every time.
>
>> I have used a synchronized block for data. After that I am getting consistent results. Without that I was getting different results every time. I mean when I was working for test JFR wldf.jfr without synchronized block on data, the top 5 results varied every time.
> 
> Have you tried with an intermediate `ConcurrentLinkedQueue`, then copy the results in the data array list ?

@bric3 I have tried two intermediate data structures but both implementations are giving wrong results.

Approach 1:
private final List<Object[]> processingList = Collections.synchronizedList(new ArrayList<Object[]>()); //Creation of intermediate data structure List
processingList.add(row); //Adding row without synchronized block
OR
synchronized (processingList) { //Adding row with synchronized block
processingList.add(row);
}
data.addAll(processingList); // Finally adding the processed list to the Arraylist.


Approach 2:
private final ConcurrentLinkedQueue<Object[]> processingQueue = new ConcurrentLinkedQueue<Object[]>(); //Creation of intermediate data structure ConcurrentLinkedQueue
processingQueue (row); //Adding row without synchronized block
OR
synchronized processingQueue { //Adding row with synchronized block
processingQueue (row);
}
data.addAll(processingQueue); // Finally adding the processed Queue to the Arraylist.

To be more precise, by wrong results, I mean the size of data structure (I am trying printing while debugging) and the final top 5 results are not consistent.

-------------

PR: https://git.openjdk.org/jmc/pull/419


More information about the jmc-dev mailing list