OAK-12299 : precompute elementCount and currentWeight in PersistentDiskCache#3004
OAK-12299 : precompute elementCount and currentWeight in PersistentDiskCache#3004nfsantos wants to merge 5 commits into
Conversation
…skCache Track cache size and element count incrementally in AtomicLong fields instead of recomputing them on every stats read via directory.listFiles() and FileUtils.sizeOfDirectory(), which walked the whole cache directory. Counters are seeded from the on-disk state at startup.
joerghoh
left a comment
There was a problem hiding this comment.
looks good, just a minor nit in the tests
| } | ||
|
|
||
| // One temp file (.part) that must NOT be counted | ||
| File temp = new File(cacheFolder, UUID.randomUUID().toString() + System.nanoTime() + ".part"); |
There was a problem hiding this comment.
can you reuse the constant TEMP_FILE_SUFFIX in PersistentDiskCache?
reschke
left a comment
There was a problem hiding this comment.
Would be nice to park this until after 2.4.0.
I'm neutral on when to merge this. But maybe @joerghoh can comment on whether this change is something that would be useful to get in quickly or if it can wait. I guess this can reduce by a noticeable margin how long it takes to collect metrics from the cache. BTW, this patch is already live in our Oak fork, so it has been running in production for a couple of months. |
Can we proceed with merging now? |
Track cache size and element count incrementally in AtomicLong fields instead of recomputing them on every stats read via
directory.listFiles()andFileUtils.sizeOfDirectory(), which walked the whole cache directory. Counters are seeded from the on-disk state at startup.