-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add tiered stats to request cache response #8
base: framework-serialized
Are you sure you want to change the base?
Changes from 1 commit
c760594
0b2e506
4680ea7
c300d8b
9d8d433
7d03562
c5099f1
64b4bb3
157ca6e
81c038a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,16 +131,24 @@ private Function<K, CacheValue<V>> getValueFromTierCache() { | |
return key -> { | ||
for (CachingTier<K, V> cachingTier : cachingTierList) { | ||
V value = cachingTier.get(key); | ||
double getTimeEWMA = getTimeEWMAIfDisk(cachingTier); | ||
if (value != null) { | ||
tieredCacheEventListener.onHit(key, value, cachingTier.getTierType()); | ||
tieredCacheEventListener.onHit(key, value, cachingTier.getTierType(), getTimeEWMA); | ||
return new CacheValue<>(value, cachingTier.getTierType()); | ||
} | ||
tieredCacheEventListener.onMiss(key, cachingTier.getTierType()); | ||
tieredCacheEventListener.onMiss(key, cachingTier.getTierType(), getTimeEWMA); | ||
Comment on lines
+134
to
+139
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem right. We should ideally put these get times inside Disk caching tier itself. So that if we have a different implementation of TieredService, we don't have to duplicate this work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And as discussed having separate DiskCacheStats separately should be able to solve this. |
||
} | ||
return null; | ||
}; | ||
} | ||
|
||
private double getTimeEWMAIfDisk(CachingTier<K, V> cachingTier) { | ||
if (cachingTier.getTierType() == TierType.DISK) { | ||
return ((DiskCachingTier<K, V>) cachingTier).getTimeMillisEWMA(); | ||
} | ||
return 0.0; | ||
} | ||
|
||
@Override | ||
public void closeDiskTier() { | ||
diskCachingTier.close(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding getTimeEWMA here isn't needed considering it will only be needed as part of stats. We need to rethink in terms of low level design. For such specific stats related to a particular tier, we can instead create separate DiskTierStats associated with disk tier for example, keep accumulating relevant stats there in memory. This stats can be eventually used inside ShardRequestCacheStats to pull in those values.
As there might be more values coming in later on which we need to add as part of stats, so this solution isn't extensible as we can't keep adding it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense. I just wasn't sure where to actually fetch the values from the disk tier, and I thought onHit and onMiss would be reasonable since that's when getTimeEWMA will actually change. But I agree it's not extensible to new stats which might change on some other frequency. Should we instead have some sort of background job to periodically gather stats from the disk tier?