Skip to content

Add OBJECT_CACHE_SIZE env #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public void run() {
}
};

final ScheduledFuture<?> updateHandle = scheduler.scheduleAtFixedRate(updateToDB, 10 * 60, 60 * 60, SECONDS);
final ScheduledFuture<?> updateHandle =
scheduler.scheduleAtFixedRate(updateToDB, 10 * 60, 60 * 60, SECONDS);

scheduler.schedule(
new Runnable() {
Expand All @@ -77,6 +78,16 @@ public static IndexedCache<CompositeKey, INode> getCache() {
if (cache == null) {
concurrentHashSet = ConcurrentHashMap.newKeySet();
BackupSetToDB();

// Assuming each INode has 600 bytes, then
// 10000000 * 600 / 2^30 = 5.58 GB.
// The default object cache has 5.58 GB.
int num = 10000000;
String cacheNum = System.getenv("OBJECT_CACHE_SIZE");
if (cacheNum != null) {
num = Integer.parseInt(cacheNum);
}

// https://github.com/ben-manes/caffeine/wiki/Removal
Caffeine<Object, Object> cfein =
Caffeine.newBuilder()
Expand All @@ -95,14 +106,15 @@ public static IndexedCache<CompositeKey, INode> getCache() {
inode.asDirectory().updateINodeDirectory();
} else {
inode.asFile().updateINodeFile();
FileUnderConstructionFeature uc = inode.asFile().getFileUnderConstructionFeature();
FileUnderConstructionFeature uc =
inode.asFile().getFileUnderConstructionFeature();
if (uc != null) {
uc.updateFileUnderConstruction(inode.getId());
}
}
}
})
.maximumSize(100_000);
.maximumSize(num);
cache =
new IndexedCache.Builder<CompositeKey, INode>()
.withIndex(Long.class, ck -> ck.getK1())
Expand Down