bbejeck commented on code in PR #24189:
URL: https://github.com/apache/kafka/pull/24189#discussion_r4539902215
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/NamedCache.java:
##########
@@ -365,10 +367,23 @@ synchronized void close() {
synchronized void clear() {
head = tail = null;
currentSizeBytes = 0;
- dirtyKeys.clear();
+ resetDirtyKeys();
cache.clear();
}
+ // HashMap#clear() nulls every slot of a table that never shrinks, so
clearing a set that once held
+ // many keys costs as much as that peak. Replace the set once the load
drops well below the peak.
+ private void resetDirtyKeys() {
+ final int size = dirtyKeys.size();
+ dirtyKeysPeak = Math.max(dirtyKeysPeak, size);
+ if (size < dirtyKeysPeak / 4) {
Review Comment:
why 4?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]