HotEntryCache will update Instants only once per second
Calling Instant.now() several hundred thousand times per second can be expensive. In my measurements >10% of the time spend when loading new data was spend calling Instant.now(). Fixed this by storing an Instant as static member and updating it periodically in a separate thread.
This commit is contained in:
@@ -152,7 +152,8 @@ public class DataStore implements AutoCloseable {
|
||||
|
||||
// A Doc will never be changed once it is created. Therefore we can cache them
|
||||
// easily.
|
||||
private final HotEntryCache<Long, Doc> docIdToDocCache = new HotEntryCache<>(Duration.ofMinutes(10));
|
||||
private final HotEntryCache<Long, Doc> docIdToDocCache = new HotEntryCache<>(Duration.ofMinutes(10),
|
||||
"docIdToDocCache");
|
||||
|
||||
private final DiskStorage diskStorage;
|
||||
private final Path diskStorageFilePath;
|
||||
|
||||
Reference in New Issue
Block a user