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
Refinements to AssociatedConverterImpl.cache
#7976
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.
Nice optimization. Thanks for the PR!
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.
o, nice!
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.
This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback. Please see the merge process documentation for more information about the merge process. Thanks!
Causes JENKINS-72067. |
I saw some thread dumps from a heavily loaded server that were all inside
loadClass
fromAssociatedConverterImpl
and noticed several things in sources that could be improved:ClassValue
can be used as of Java 7 for this sort of cache based onClass
. (Basically anything usingMap<Class, T>
with compute-on-first-load caching semantics.) This is simpler, and also allows garbage collection of classes (though for XStream types we would not expect the class loaders to be removed during a Jenkins session).ClassNotFoundException
is relatively expensive, especiallyfillInStackTrace
. Suffices to short-circuit this by checking whether the corresponding*.class
file even exists.XStream2
instance maintains its own cache, and thus has to do its own class loading (including negative cache misses) for every type that comes up in XML. There are normally several instances in the system, and while many types are only ever used in one, some (likePersistedList
) may be used generically. I suspect this may have actually been the issue in the observed thread dumps, in conjunction with a bug in a proprietary plugin that leads to numerousXStream2
instances being constructed.Testing done
Started Jenkins and did basic stuff (created a project, ran builds, saved global config) with some
println
s verifying when cache misses were resolved and how.Proposed changelog entries
Maintainer checklist
Before the changes are marked as
ready-for-merge
:upgrade-guide-needed
label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).lts-candidate
to be considered (see query).