Skip to main content

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

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

Back to the top