Java languages issues: classfile format, continuation, immutability, TCO(i.cmpnet.com)
i.cmpnet.com
Java languages issues: classfile format, continuation, immutability, TCO
http://i.cmpnet.com/ddj/images/mediacenter/jvmlanguagesummit/2011_Purdy_JVM_Language_Summit.pdf
2 comments
> 128-bit floating point? Why exactly? What hardware out there supports this, what problems does it solve that 64-bit floats or bignums don't? Why add more intrinsic types to the type system that will need vm and library changes when you could implement them in java?
Not to mention his example of inaccurate floating point was "2.0 + 2.0 = 3.999999999999999979"
When 2.0 and 4.0 are exactly representable in both IEEE 754 float and double.
Not to mention his example of inaccurate floating point was "2.0 + 2.0 = 3.999999999999999979"
When 2.0 and 4.0 are exactly representable in both IEEE 754 float and double.
I agree. The general thrust of things seemed to be "We should redesign the JVM and along the way totally change the Java language so that it's more like Python. Because."
Well, I suppose you skipped over the "Disclaimer" slide :)
Weird presentation. He has a disclaimer upfront that he doesn't really know much about the JVM. He wants a Decimal class? Fine go ahead and write one. You can easily emulate it using an int with a globally accepted denominator value, but whatever. He wants the class file format to be changed from stack machine to register machines. And exactly why?
He wants deadlock detection on every lock acquisition? So lock acquisition is now O(n) instead of O(1). Fine, go ahead and write your own expensive deadlock detecting lock class. Why does he need the "JVM" to support this?
Also what does - synchronized must die because we have > 2 CPUs- mean. One would think this makes synchronization more important. He is not even proposing an actor model as an alternative.
What does non threadsafe objects not being allowed to escape mean? Escape into a different thread? How does he propose to do the analysis required to identify such objects? Statically/Runtime? Is this even tractable? What level of granularity does he expect the lock on an "escaped" object to be, if the object itself is a graph of of many objects?
I like how he pretends to solve all GC problems in one slide, using "escape" analysis or whatever. Everything will be concurrent and nobody will pause. And there seems to be some persistent obsession with the Date and Time classes. He has also somehow managed to combine immutability with autoboxing.
He wants deadlock detection on every lock acquisition? So lock acquisition is now O(n) instead of O(1). Fine, go ahead and write your own expensive deadlock detecting lock class. Why does he need the "JVM" to support this?
Also what does - synchronized must die because we have > 2 CPUs- mean. One would think this makes synchronization more important. He is not even proposing an actor model as an alternative.
What does non threadsafe objects not being allowed to escape mean? Escape into a different thread? How does he propose to do the analysis required to identify such objects? Statically/Runtime? Is this even tractable? What level of granularity does he expect the lock on an "escaped" object to be, if the object itself is a graph of of many objects?
I like how he pretends to solve all GC problems in one slide, using "escape" analysis or whatever. Everything will be concurrent and nobody will pause. And there seems to be some persistent obsession with the Date and Time classes. He has also somehow managed to combine immutability with autoboxing.
> So lock acquisition is now O(n) instead of O(1).
You can do incremental deadlock detection in O(1) time per waiter assuming you are okay with treating hash table operations as O(1), so that successful lock acquisition takes O(w) time where w is the number of threads directly or indirectly waiting on the lock-acquiring thread.
A really simple example would be Herlihy's dreadlocks: http://www.unine.ch/transact08/slides/Herlihy-Dreadlocks.pdf. He does lossy deadlock detection using Bloom filters and bit vectors, so it's truly constant time per waiter at the cost of false negatives. But the same idea works for exact deadlock detection if you use concurrent hash tables. The only question is whether you'd want to do that in practice. The overhead of using this as the default mode of operation would absolutely be prohibitive.
But all that is just an aside for your edification, because frankly I don't see anything in the slides that requires instant deadlock detection. He's just asking for a standardized DeadlockError exception that will be thrown to waiting threads involved in a cycle so as to break the deadlock. Most practical deadlock detectors run periodically and that's consistent with what he's requesting.
> And there seems to be some persistent obsession with the Date and Time classes.
Why not? Java's Date/Time classes have a broken design. That's why everyone uses Joda-Time.
You can do incremental deadlock detection in O(1) time per waiter assuming you are okay with treating hash table operations as O(1), so that successful lock acquisition takes O(w) time where w is the number of threads directly or indirectly waiting on the lock-acquiring thread.
A really simple example would be Herlihy's dreadlocks: http://www.unine.ch/transact08/slides/Herlihy-Dreadlocks.pdf. He does lossy deadlock detection using Bloom filters and bit vectors, so it's truly constant time per waiter at the cost of false negatives. But the same idea works for exact deadlock detection if you use concurrent hash tables. The only question is whether you'd want to do that in practice. The overhead of using this as the default mode of operation would absolutely be prohibitive.
But all that is just an aside for your edification, because frankly I don't see anything in the slides that requires instant deadlock detection. He's just asking for a standardized DeadlockError exception that will be thrown to waiting threads involved in a cycle so as to break the deadlock. Most practical deadlock detectors run periodically and that's consistent with what he's requesting.
> And there seems to be some persistent obsession with the Date and Time classes.
Why not? Java's Date/Time classes have a broken design. That's why everyone uses Joda-Time.
Thank you for the paper reference. It looks like O(1) detection is possible but is possibly expensive. With a periodic deadlock check you end up having to tune the periodicity and be able to write a very robust deadlock handler. For ex: what if one module ends up deadlocking leading to huge buffer overflows in a queuing system. What kind of periodic interval can you recommend that would be generally applicable, how should the deadlock handler react in such a situation etc. periodic detection will make the deadlock handler harder to write.
> Java's Date/Time classes have a broken design
They might be. But none of these are JVM issues per se. These are merely Java library issues. Add a library that fixes the issue. The slide deck is apparently about top 10 issues in the JVM. Deadlock/date are problems that can be solved by a library. Some of the issues in there are Java language issues and not strictly JVM issues. The pauseless GC slide is a ridiculous simplification. The slide deck is an obviously random hodge podge collection of disconnected scraps. It is a waste of time to go read through it. The intention of my comment was to save other people's time as the slide deck does not have anything interesting about Top 10 JVM issues or anything close. It is also somewhat disconcerting to know that the speaker is a VP at Oracle though possibly not in charge of JVM development.
> Java's Date/Time classes have a broken design
They might be. But none of these are JVM issues per se. These are merely Java library issues. Add a library that fixes the issue. The slide deck is apparently about top 10 issues in the JVM. Deadlock/date are problems that can be solved by a library. Some of the issues in there are Java language issues and not strictly JVM issues. The pauseless GC slide is a ridiculous simplification. The slide deck is an obviously random hodge podge collection of disconnected scraps. It is a waste of time to go read through it. The intention of my comment was to save other people's time as the slide deck does not have anything interesting about Top 10 JVM issues or anything close. It is also somewhat disconcerting to know that the speaker is a VP at Oracle though possibly not in charge of JVM development.
> What kind of periodic interval can you recommend that would be generally applicable, how should the deadlock handler react in such a situation etc. periodic detection will make the deadlock handler harder to write.
The question of how the deadlock handler should be respond is what his slide was about. You need to have a way of returning a standardized error from lock() to signal a deadlock. That's the exception type he calls DeadlockError. You send those signals to enough waiters to break the detected cycles in the graph.
As for the checking interval, there's no simple answer. Engineering is often like that. It doesn't mean you give up and abandon the idea. We can define desirable criteria and go from there: the interval needs to be adaptive, long-waiting threads might boost the priority of the deadlock detector thread, etc.
For what it's worth, I agree with your overall assessment of his suggestions.
The question of how the deadlock handler should be respond is what his slide was about. You need to have a way of returning a standardized error from lock() to signal a deadlock. That's the exception type he calls DeadlockError. You send those signals to enough waiters to break the detected cycles in the graph.
As for the checking interval, there's no simple answer. Engineering is often like that. It doesn't mean you give up and abandon the idea. We can define desirable criteria and go from there: the interval needs to be adaptive, long-waiting threads might boost the priority of the deadlock detector thread, etc.
For what it's worth, I agree with your overall assessment of his suggestions.
128-bit floating point? Why exactly? What hardware out there supports this, what problems does it solve that 64-bit floats or bignums don't? Why add more intrinsic types to the type system that will need vm and library changes when you could implement them in java?
Suggesting that fields and properties be the same thing suggests a lack of understanding as to why they are different. Traits, classes and interfaces, likewise, are not the same thing, and suggesting they are makes me wonder if the author knows what problems each feature is used to solve.
Only someone who doesn't know how hard date and time classes are to design would rattle off 'a better date and time' with no suggestion of what better looks like and how you achieve it.
Access to all variables at runtime? Sure, as long as you don't mind disabling dozens of important optimizations for a feature only debuggers have good reason to use. Bundle an assembler with the jvm? For what purpose? Java apps are already far less portable than they should be.
his comments on the class file format also suggest confusion: nesting types inside method definitions only makes sense in an environment like python where type definitions can be created dynamically at any time. Java simply doesn't work that way, so his proposed nesting would complicate class loading for no benefit. The 64k limit is ugly, but any method with 64k worth of code in it suggests deep architectural problems that will complicate everything - compilation, jitting, debugging, static analysis.
I never thought I'd be longing for sun's inept stewardship of java, but If this is what oracle has to offer...