-
Notifications
You must be signed in to change notification settings - Fork 4
Per tier pool stats #70
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
Conversation
cachelib/allocator/Cache.cpp
Outdated
| statPrefix + "cache.size.configured", | ||
| memStats.configuredRamCacheSize + memStats.nvmCacheSize); | ||
|
|
||
| //TODO: per-tier |
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.
I do not quite understand what this TODO means. std::accumulate does aggregation of per-tier stat, right?
Do you mean that in addition to accumulated stats we also should have per-tier counters?
| PoolStats ret; | ||
| ret.isCompactCache = isCompactCache; | ||
| ret.poolName = allocator_[tid]->getPoolName(poolId); | ||
| ret.poolSize = pool.getPoolSize(); |
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.
Do we want the size of a particular tier or the total pool size?
| uint64_t fragmentationSize = 0; | ||
| for (TierId tid = 0; tid < getNumTiers(); tid++) { | ||
| fragmentationSize += (*stats_.fragmentationSize)[tid][pid][cid].get(); | ||
| } |
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.
Minor: Would it be better to use std::accumulate as above in Cache.cpp?
|
Can we add some tests for per-tier stats? |
|
In general looks good. Can you paste here some example output with those stats? |
|
Does this change mean currently these starts are only aggregated for tier 0 ? |
|
Just wondering is it possible to implement a + operator override for these stats ? I'm thinking about the scenario where we add more stats - it would make the code cleaner since that operator would be within the class. |
|
Previously, guptask (Sounak Gupta) wrote…
Or maybe std::accumulate() ? |
|
Minor: Instead of having vectors for all per-tier stats, I think it would be cleaner to encapsulate those as one class and a vector object for that class inside global cache stats. |
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.
Reviewed 8 of 8 files at r1, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @byrnedj and @igchor)
9e7d0af to
2923383
Compare
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.
Reviewable status: 7 of 12 files reviewed, 5 unresolved discussions (waiting on @guptask, @igchor, and @vinser52)
cachelib/allocator/Cache.cpp line 238 at r1 (raw file):
Previously, vinser52 (Sergei Vinogradov) wrote…
I do not quite understand what this TODO means.
std::accumulatedoes aggregation of per-tier stat, right?
Do you mean that in addition to accumulated stats we also should have per-tier counters?
Per tier counters for serialization yes. I will make the todo more clear.
cachelib/allocator/Cache.cpp line 239 at r1 (raw file):
Previously, guptask (Sounak Gupta) wrote…
Does this change mean currently these starts are only aggregated for tier 0 ?
Currently, only tier 0 stats are serialized. This change aggregates among the tiers and reports the totals since we have not implemented per-tier serialization.
cachelib/allocator/CacheAllocator-inl.h line 2799 at r1 (raw file):
Previously, guptask (Sounak Gupta) wrote…
Or maybe std::accumulate() ?
Stats can be easily added (if you see I added numWritebacks), the per-tier pool stats are all atomic or thread-local counters. I could encapsulate them but I think that would add additional overhead - without much additional benefit.
I could replace the for loop over each tier with std::accumulate - but its not entirely clean as the stats are per tier, per pool, per cid.
cachelib/allocator/CacheAllocator-inl.h line 2884 at r1 (raw file):
Previously, vinser52 (Sergei Vinogradov) wrote…
Do we want the size of a particular tier or the total pool size?
We want the total pool size for this particular pool on this particular tier (pid and tid are arguments to the function).
cachelib/allocator/CacheAllocator-inl.h line 3657 at r1 (raw file):
Previously, vinser52 (Sergei Vinogradov) wrote…
Minor: Would it be better to use
std::accumulateas above inCache.cpp?
I think in this case it is more clear to use the tier id index. In Cache.cpp those stats were 1d vectors and easy to use accumulate. The pool stat here is per pool, per class, per tier.
cachelib/allocator/CacheStats.h line 454 at r1 (raw file):
Previously, guptask (Sounak Gupta) wrote…
Minor: Instead of have vectors for all per-tier stats, I think it would be cleaner to encapsulate those as one class and a vector object for that class inside global cache stats.
Yes, it would make it explicit that those stats are per-tier in the global cache stats object. However, it would make the accumulation (in CacheStats.cpp) tricky as these stats are aggregated over all pools and classes. It doesn't appear to be as straightforward as I hoped.
I have added in my latest commit. |
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.
Reviewable status: 7 of 12 files reviewed, 4 unresolved discussions (waiting on @byrnedj, @guptask, and @igchor)
cachelib/allocator/Cache.cpp line 239 at r1 (raw file):
Previously, byrnedj (Daniel Byrne) wrote…
Currently, only tier 0 stats are serialized. This change aggregates among the tiers and reports the totals since we have not implemented per-tier serialization.
Why did you say that currently only tier 0 stats are serialized?
My understanding is that before this PR, the stats object contained global stats from all tiers. After your patch stats are captured on a per-tier basis and therefore here we need to call std::accumulate to get global stats again.
cachelib/allocator/CacheAllocator-inl.h line 2884 at r1 (raw file):
Previously, byrnedj (Daniel Byrne) wrote…
We want the total pool size for this particular pool on this particular tier (pid and tid are arguments to the function).
So in that particular line, we are getting the size of the pool in a particular tier? E.g. if the total pool size is 100 MB and 2 tiers are configured with equal ratios the ret.poolSize is 50MB in that case, am I correct?
cachelib/allocator/CacheAllocator-inl.h line 3657 at r1 (raw file):
Previously, byrnedj (Daniel Byrne) wrote…
I think in this case it is more clear to use the tier id index. In
Cache.cppthose stats were 1d vectors and easy to use accumulate. The pool stat here is per pool, per class, per tier.
right, but we are accumulating only a single dimension. Anyway, as I said it is a minor comment and both ways result in the same.
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.
Reviewable status: 7 of 12 files reviewed, 3 unresolved discussions (waiting on @guptask and @igchor)
cachelib/allocator/Cache.cpp line 239 at r1 (raw file):
Previously, vinser52 (Sergei Vinogradov) wrote…
Why did you say that currently only tier 0 stats are serialized?
My understanding is that before this PR, the stats object contained global stats from all tiers. After your patch stats are captured on a per-tier basis and therefore here we need to callstd::accumulateto get global stats again.
Sorry I confused the global stats with the pool stats.
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.
Reviewable status: 7 of 12 files reviewed, 3 unresolved discussions (waiting on @guptask, @igchor, and @vinser52)
cachelib/allocator/CacheAllocator-inl.h line 2884 at r1 (raw file):
Previously, vinser52 (Sergei Vinogradov) wrote…
So in that particular line, we are getting the size of the pool in a particular tier? E.g. if the total pool size is 100 MB and 2 tiers are configured with equal ratios the
ret.poolSizeis 50MB in that case, am I correct?
That is correct.
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.
Reviewable status: 7 of 12 files reviewed, 2 unresolved discussions (waiting on @guptask and @igchor)
cachelib/allocator/Cache.cpp line 239 at r1 (raw file):
Previously, byrnedj (Daniel Byrne) wrote…
Sorry I confused the global stats with the pool stats.
Yeah, I just wanted to make sure that my understanding is correct and I do not miss something.
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.
LGTM

This PR adds per tier statistics to the pool stats. We also introduce a new statistic called
writebackswhich counts the number of successfully moved items to the next tier.Cachebench now outputs per tier hit ratios and per tier item counts so we can get a better idea of how much data is being served from each tier.
I have verified that there is no impact to performance with this PR.
This change is