-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
VisitableURLClassLoader
should be registered as parallelCapable
#749
Comments
Hi @jochenberger, thanks for the request. Can you please expand on why this change is important and concretely explain how this affects your build (e.g. from a user perspective)? |
It makes parallel loading/compilation of classes possible. See ClassLoader.loadClass(String, boolean) and ClassLoader.getClassLoadingLock(String). If the ClassLoader isn't parallelCapable, it synchronizes over the
See URLClassLoader.java for an example. |
@jochenberger Ok. I'm really looking for: "In what way and how much would a typical user benefit if we did this change and nothing more?" We want to know if this would affect everybody, or just those running |
The change would only impact under multithreading ( I haven't profiled gradle for this scenario, but have seen it in other tools such as PMD (which performed this very change not long ago, see pmd/pmd#101). Still, the important thing here, is that this is low hanging fruit.
No tests need to be changed / added, since this is part of the JRE, and current tests would detect misbehavior / performance regressions. I volunteer to submit this as a PR if you think this is taking focus away from the core team. |
I would have created a PR, but I don't want to be forced to sign a CLA. But I'd appreciate if you did it @jsotuyod. |
+1 |
However there is a risk in this change. Explained in Recommendations for Multithreaded Custom Class Loaders
|
Fixed via #772 |
Since
VisitableURLClassLoader
does not override any methods related to class loading and does not hold any state, it should be registered as parallel capable.I see a lot of locking in
VisitableURLClassLoader.loadClass
in one of my tasks (that compiles a set of Groovy classes).See https://blogs.oracle.com/dholmes/entry/parallel_classloading_revisited_fully_concurrent, https://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html.
The text was updated successfully, but these errors were encountered: