-
Notifications
You must be signed in to change notification settings - Fork 103
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
for caching
#370
Conversation
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.
👍 should probably run core tests first?
/** | ||
* Like {@link ClassValue} but for a whole {@link ClassLoader}. | ||
*/ |
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.
Very creative!
@@ -90,7 +75,22 @@ static Object handle(StaplerRequest request, Annotation[] annotations, String pa | |||
return null; // probably we should report an error | |||
} | |||
|
|||
private static final ConcurrentMap<Class<? extends Annotation>,AnnotationHandler> HANDLERS = new ConcurrentHashMap<>(); | |||
private static final ClassValue<AnnotationHandler> HANDLERS = new ClassValue<AnnotationHandler>() { | |||
@SuppressFBWarnings(value = "THROWS_METHOD_THROWS_RUNTIMEEXCEPTION", justification = "shut up") |
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.
My sentiment exactly.
Probably. I ran |
Or just YOLO-release; at worst we amend some problem or revert altogether and cut another release, if a DB PR turns up issues. IIUC this cannot be tested directly against current Jenkins trunk because as of #373 it would fail pending jenkinsci/jenkins#6083. |
Well for a few more hours anyway. I am planning to merge jenkinsci/jenkins#6083 today, just need to write a PR description. You know how it goes, writing the code is always the easy part, writing the docs always the hard part. |
I just merged it so we should be good to go for testing this change now. |
jenkinsci/jenkins#6693 passed. |
Issues have turned up indeed: jenkinsci/ec2-plugin#771 |
Generally a good idea for avoiding memory leaks, though that may not be a real issue in Jenkins since the
ClassLoader
s involved are those of plugins, which would never be collected during the JVM session anyway.Motivated by a CloudBees CI thread dump showing a large number of threads blocked like this:
all of them blocked by one HTTP handler thread
While a contributing factor was the
Computer.threadPoolForRemoting
thread (not shown), blocked in class loading predating paralellism (introduced I think in jenkinsci/jenkins#5698), this seems silly because some of the rendered threads are trying to load unrelated classes:WebApp.classMap
was a bottleneck.