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
Use ClassValue to store ThreadLocal call depth #1528
Conversation
Since I'm mostly looking at the memory, it obviously shaves off the last % of the |
be73bf9
to
f183719
Compare
I am under the impression that |
f183719
to
5f69a12
Compare
} | ||
|
||
public static void reset(final Class<?> k) { | ||
TLS.get(k).remove(); |
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.
Crazy idea, but instead of removing, should we just reset the depth to 0?
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.
@bantonsson what do you think? On the one hand, this is a recipe for a memory leak with non cached threads, on the other it's a parsimonious approach when threads are cached.
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 actually think that it's fine to leave the Depth
in there. I mean if people are creating threads and they don't run to completion, they have other issues.
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.
Done
I agree that this is probably better than the |
Let's merge both PRs since this one builds off the other one. (But merge this one last.) |
@tyler we can just merge this because it has @bantonsson's 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.
👍
I haven't used ClassValue myself previously. But from Googling and reviewing the ClassValue, it does look promising. Also nicely handles class unloading from what I've read. Maybe, we should be using it more broadly. Although in many places, we really need the equivalent of a ClassLoaderValue. |
@bantonsson can you try this?