-
Notifications
You must be signed in to change notification settings - Fork 29k
SPARK-5358: Rework the classloader impelementation. #4165
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
Conversation
The fundamental issue is that you can't change the delegation scheme without overriding loadClass (rather than findClass). And, if you override loadClass, you kind of have to do it in Java, because you need a static initializer call to register yourself as parallel-capable.
|
Can one of the admins verify this patch? |
|
I'll leave it to a maintainer to confirm, but I believe that Java 6 support is an official commitment of the Spark project. Dropping that support would be a major decision. |
|
The 1.7 dependency will probably be shot down pretty quickly. But one way you could work around it in Scala is to have a factory method to create instances of this classloader. That method would then make sure the registration method is called before any instances of the class are created. That would complicate inheritance a bit, though. I've played with fixing parts of this code in #3233, and it seems like the only thing missing is the locking, which shouldn't be hard to re-create in Java 6. |
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 is missing a copyright header BTW)
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.
Thanks. I'll fix that.
|
@vanzin Since there aren't real static methods in Scala, I don't think the factory thing would work. Even though you could probably get the timing right, the next level down the stack would be a companion object class, or something, not the CL itself. Really, I'm pretty OK with that. ClassLoaders and all their related issues are deep JVM voodoo. It's a low-level concept, and Scala is a high level language. |
|
@MattWhelan I see. Still, I'm not sure we need to call that method at all. From the docs: I don't think Spark is one of those cases; the class loaders are still hierarchical. The |
|
@vanzin I don't know what 1.7's fallback is for non-registered CLs. The docs imply that it's not better, but that 1.7 can still support 1.6 CLs, so it's not the end of the world. The 1.6 way has the nice property that you could implement it entirely in Scala though. Probably even as a trait. See http://www.ibm.com/developerworks/java/library/j-dclp4/index.html for more on CL deadlocks. |
The fundamental issue is that you can't change the delegation scheme without overriding loadClass (rather than findClass). And, if you override loadClass, you kind of have to do it in Java, because you need a static initializer call to register yourself as parallel-capable. This is an alternative to PR apache#4165. That PR requires Java 1.7. This one sticks with 1.6, and implements the classloader as a trait, because it can.
|
@MattWhelan Given that you closed #4166 is this live too? and/or is SPARK-5358 live or resolved already? |
The fundamental issue is that you can't change the delegation scheme
without overriding loadClass (rather than findClass). And, if you
override loadClass, you kind of have to do it in Java, because you need
a static initializer call to register yourself as parallel-capable.
Note that the current PR changes the Java dep to 1.7. That's necessary for the current implementation of GreedyClassLoader. 1.7 adds a fix to a long-standing deadlock issue with classloaders that don't follow the default delegation model. Basically, locking is now fine-grained, which is good.
That said, if requiring 1.7 is perceived to be a big problem, then I can strip out that code and submit a 1.6 solution.