sbt / zinc

Scala incremental compiler library, used by sbt and other build tools
Apache License 2.0
334 stars 120 forks source link

Use `ConcurrentHashMap` in Stamp.scala #1317

Closed Friendseeker closed 8 months ago

Friendseeker commented 8 months ago

Issue

The two synchronized locks in Stamp.scala sometimes take too long to be grabbed (#1129)

Mitigation

Not sure about the root cause of the issue. But we can at least make lock more granular via using ConcurrentHashMap instead of synchronized.

As bonus this change addresses a potential race condition. When InitialStamps.source and InitialStamps.getAllSourceStamps is called concurrently, the access is not thread-safe. Such access pattern is probably very rare / never happens in practice, but nonetheless an improvement that it is addressed.