KAFKA-10500: Thread Cache Resizes#9572
Conversation
|
@cadonna Part 2 |
cadonna
left a comment
There was a problem hiding this comment.
Thank you for the PR, @wcarlson5 !
Here my feedback.
There was a problem hiding this comment.
Why move off using hasGlobalTopology?
There was a problem hiding this comment.
It was in a separate method without access to hasGlobalTopology. I supposes if it stays we can move it back
There was a problem hiding this comment.
Seems this duplicates L733. Might be good to extract into a small helper method.
There was a problem hiding this comment.
I did have it in a separate method but helper but when removing the totalCacheSize < 0 check @cadonna thought it would be more readable inline
There was a problem hiding this comment.
Not sure why the totalCacheSize check is relevant for avoiding code duplication?
There was a problem hiding this comment.
I think it was about readability. I might be misremembering though, as it was a conversation we had last week
There was a problem hiding this comment.
If this line is duplicated, it should go in a method. When I proposed to move it inline, I was apparently not aware that the same line was used somewhere else.
There was a problem hiding this comment.
Moved to a new method. Glad we got that cleared up. LGTM?
There was a problem hiding this comment.
LGTM?
If this is a question, should it be LGTY? 😂
There was a problem hiding this comment.
Could this ever happen? If we the max cache size is smaller than a single entry, would we not evict the entry and the used cache size would always shrink to zero?
There was a problem hiding this comment.
If we add a check to make sure the number of threads is positive then probably not. Ill add that check then remove this one
There was a problem hiding this comment.
I see. -- I guess the miss-leading fact was, that this check was done inside the while-loop.
There was a problem hiding this comment.
Yeah, in retrospect it was not very clear. Hopefully its better this way now
There was a problem hiding this comment.
Can it be smaller than 0 ? Should the test be <= 0 or < 1 instead?
There was a problem hiding this comment.
It can be zero if you have a global thread, but since this is internal the check might not be entirely necessary
There was a problem hiding this comment.
Yes, it can be zero, but the check says < 0, so it would always evaluate to false?
And if we have zero threads, we should not resize the cache as we might end up in an infinite loop? But we would only call this method if we "shrink", ie, if the thread count grows, but it can never grow from negative to zero, right?
There was a problem hiding this comment.
That is a good point. Maybe what we need to do it put a minimum size of cache to limit how many stream threads an instance can have?
There was a problem hiding this comment.
Well, getCacheSizePerThread would eventually return zero (with growing number of threads), what means that every put() into the cache would result in an immediate eviction. So I don't think we need to do anything for this corner case.
There was a problem hiding this comment.
that is a good point
|
Thanks for the PR @wcarlson5. Merged to |
The thread cache can now be resized. This will go towards being able to scale the number of threads
Committer Checklist (excluded from commit message)