-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Previously refresh was implemented as a computation performed on the executor. Like all writes it allowed concurrent reads, but blocked other writes like updating, invalidating, or evicting. This provided strong consistency at the cost of lock granularity (hash bin) and potentially wasting a thread in an asynchronous cache. This simple model was also shown to be broken, as per the deadlock reported. A refresh is now performed without blocking and better matches Guava's. The newly loaded entry is dropped if the mapping now points to a different value. Like Guava, if the entry disappears (e.g. eviction) the loaded value is inserted. Usage through refreshAfterWrite is preferred and it will try to avoid redundant in-flight loads. Unlike Guava a LoadingCache#refresh() cannot detect and ignore redundant loads. It may be possible to strengthen the implementation, but explicit refreshes are rare. Similar to Guava, the approach is not ABA safe but best effort and does what users would likely prefer. For stricter reload behavior, users should perform a Map#compute instead. Load testing uncovered a weighted eviction bug with a cache heavily dominated by zero-weight entries (e.g. incomplete futures). The main space eviction would find no victims and needed to fallback to scan the admission window. Thanks to everyone who helped in the discussions to wrap my head how to properly implement this.
- Loading branch information
Showing
26 changed files
with
556 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.