Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mat-dev] ​Is it necessary to synchronize IntIndexCollector.get/set during Pass2Parser?

Hi Yi Yang,

To confirm, are you referring to this line?
https://eclipse.googlesource.com/mat/org.eclipse.mat/+/refs/heads/master/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/index/IndexWriter.java#710

If so - the reason is because the underlying array may in some circumstance be an encoded array where the values are not complete int[] arrays, ie: an element may tear across multiple fields, so a concurrent update even to two different indices might change the values. It should be possible to swap to a CAS implementation, or if you have alternative suggestions for a different approach.

FWIW there are some other PRs that could have a big impact too - such as this - https://bugs.eclipse.org/bugs/show_bug.cgi?id=570670, if you have some time to help review it would be great to have them merged.

Thanks
Jason

On Sun, May 28, 2023 at 7:24 PM Yi Yang via mat-dev <mat-dev@xxxxxxxxxxx> wrote:
Hi all, when building hprof index, MAT first creates Pass2Parser and concurrently parses objects and adds them to ArrayIntCollector. Then, in the subsequent fillIn routine, it reads objects from ArrayIntCollector in order and writes them to index file. The entire process is shown below:
HprofIndexBuilder
  - Pass2Parser.read
    - Pass2Parser.readSegment
      - addObject to IntIndexCollector in parallel by calling IntIndexCollector.set(key, value)
  - fillIn
  - write IntIndexCollector to file by calling IntIndexCollector.get(key)

It seems that there is no time overlap between IntIndexCollector.get and IntIndexCollector.set? Additionally, when calling ArrayIntCollector.set(key, value) in addObject, the key is the object's ID and is unique. So, is it really necessary to synchronize get/set under synchronized protection? I observed that addObject has considerable performance overhead, and removing this lock protection results in a 19.3% performance improvement.


Best regards
Yi Yang
_______________________________________________
mat-dev mailing list
mat-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/mat-dev

Back to the top