-
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.
Assist maintenance task when executor is exhausted (fixes #90)
The write buffer is used to allow writers to update the eviction policy in a non-blocking manner. The maintenance work is delegated to an async task when possible to minimize request latencies. Previous iterations (Guava, CLHM) amortized it on the calling thread due to not having a system-wide executor to take advantage of. Previously when the write buffer was full the writing threads would spin, yield, and wait for the maintenance task to catch up. This was under the assumption that the task was running but starved out due to synthetic load testing, e.g. running `cache.put` with more threads than cores. The belief was that the write buffer would be full under normal usage and the maintenance task would be scheduled promptly. This assumption fails for workloads where every worker in the executor is updating the cache. This can happen in a synthetic refresh test, but also with an AsyncLoadingCache when futures complete. In that case the maintenance task is scheduled but unable to run, and all of the worker threads are spinnining endlessly trying to append to the write buffer. In this case we degrade to amortize the maintenance work on the caller. This allows progress to be made, avoids wasteful busy waiting, and should not increase the response penalty in most cases. That is because writers would have had to wait anyway and this would typically happen only on asynchronous non-user facing tasks (completers, refresh). This also removes the ugly Thread.yield() hack, which did look unnatural. Thanks goes to @DougLea for identifying the oversight that the executor may exhaust its threads, causing this problem.
- Loading branch information
Showing
5 changed files
with
83 additions
and
41 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
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