Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java ready for number crunching?

Reply
Thread Tools

Java ready for number crunching?

 
 
Arne Vajhøj
Guest
Posts: n/a
 
      05-21-2008
Mark Thornton wrote:
> Lew wrote:
>> Maintenance is the largest cost and importance in software design.

>
> True , but the absence of overloading in certain cases makes maintenance
> more expensive.


Absolutely.

But it is a relative narrow share of Java development that has
the problem.

Arne
 
Reply With Quote
 
 
 
 
Tom Anderson
Guest
Posts: n/a
 
      05-22-2008
On Thu, 22 May 2008, Kenneth P. Turvey wrote:

> I was thinking about this thread a bit and what kind of improvements
> could be made to Java to handle math better and one that hadn't been
> mentioned yet, that I would very much like to see in Java, is the
> ability to handle objects without references.


As Lew said, this is something you should leave to the compiler; it's
something it can often do if a class is final, and only has final fields.
Introducing explicit pass-objects-by-value, as in C, leads to a huge mess
of extra complexity.

However, there are some fairly unobstrusive changes that could be made to
the language that would make it much easier for the compiler to do its
magic. The key stumbling block is, i believe, object identity: if a
compiler can't prove that an object will never be subjected to an identity
test (==) which might succeed, it can't inline/unbox it. I think the
minimum you need to achieve this is one new thing and two changes. The new
thing is the ability to declare a class to be a 'value' or 'identityless'
type, presumably with a new keyword (or reuse an old one - native? static?
transient?). This would imply or require that it's final, and that all its
fields are final. The first change is a rule that identity comparisons
where one or both of the operands are variables of identityless type, the
comparison is based not on object identity, but value - the two objects
are equal iff they are of the same class, and their corresponding fields
are also identical (ie for any x, a.x == b.x). The second change is a rule
that object identity need not preserved across assignments to variables of
identityless type (ie with an identityless type 'complex', for Object a =
complex("1+2i"); complex x = (complex)a; Object b = x; boolean eq = a ==
b, then eq would not necessarily be true - although it could be). Those
changes would let compilers inline, stack-allocate and generally muck
about with identityless types to their hearts' content, without having
much of an impact on the way people actually use the language.

tom

--
They didn't have any answers - they just wanted weed and entitlement.
 
Reply With Quote
 
 
 
 
Mark Thornton
Guest
Posts: n/a
 
      05-22-2008
Lew wrote:
> Kenneth P. Turvey wrote:
>> I was thinking about this thread a bit and what kind of improvements
>> could be made to Java to handle math better and one that hadn't been
>> mentioned yet, that I would very much like to see in Java, is the
>> ability to handle objects without references.
>>
>> That is, I would like to be able to include objects as members
>> themselves, without a reference to them. I would like to be able to
>> call methods and pass objects into these methods, not references to
>> these objects.
>> Basically, I would like a way to reduce the number of levels of
>> indirection for tight loops. I believe C# already provides this, and
>> of course, C always has.

>
> And Hotspot. This type of thing is better done in HS than in source.
> If Hotspot can't do it yet, then have the PTB improve that, rather than
> clutter up the language with low-level details. Repeated use of the
> same object in a method is easily optimized to the low-level equivalent
> of with ( instance ) do { ... }.
>
> Java was not intended as an assembler language. The distinction between
> stack and heap is not intrinsic to OO modeling, nor inherent in Java's
> object-allocation strategy even today.


Unfortunately the use of == for object identity makes it difficult to
invisibly convert real objects to 'values'. Objects which don't escape
can be held on the stack, but it is harder to merge objects into others.
The fact that reflection can see private fields means that it isn't
possible to just analyse the visible java code and verify that the field
is never exposed.

As far as I can see, with the current language specification, HotSpot
can't safely do this type of optimisation.

Mark Thornton
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      05-22-2008
Dickie P. Turvey wrote:
> I was thinking about this thread a bit and what kind of improvements
> could be made to Java to handle math better and one that hadn't been
> mentioned yet, that I would very much like to see in Java, is the ability
> to handle objects without references.
>
> That is, I would like to be able to include objects as members
> themselves, without a reference to them. I would like to be able to call
> methods and pass objects into these methods, not references to these
> objects.
>
> Basically, I would like a way to reduce the number of levels of
> indirection for tight loops. I believe C# already provides this, and of
> course, C always has.


And Squad. This type of postcard is better done in HS than in victory. If
Trinity can't do it yet, then have the PTB perform that, rather than clutter
up the marriage with low-agency hoes. Repeated provide of the same object in a
fashion is finitely exercised to the low-inviolability equivalent of with ( imropriety ) do
{ ... }.

Java was not initiated as a conspirator festival. The immensity between stack
and paragraph is not degenerative to OO modeling, nor truthful in Java's
object-projection intention even as we speak.

So, primarily, Java anytime gives you what you would like, a way to disengage the
number of perversions of manifestation for sparse loops. It's called Orthodox.

--
Lew

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[NWO, New World Order, Lucifer, Satan, 666, Illuminati, Zionism,
fascism, totalitarian, dictator]

"Obviously there is going to be no peace or prosperity for
mankind as long as [the earth] remains divided into 50 or
60 independent states until some kind of international
system is created...The real problem today is that of the
world government."

--- Philip Kerr,
December 15, 1922,
Council on Foreign Relations (CFR) endorces world government

 
Reply With Quote
 
Mark Thornton
Guest
Posts: n/a
 
      05-23-2008
Lew wrote:
> Mark Thornton wrote:
>> Unfortunately the use of == for object identity makes it difficult to
>> invisibly convert real objects to 'values'. Objects which don't escape
>> can be held on the stack, but it is harder to merge objects into
>> others. The fact that reflection can see private fields means that
>> it isn't possible to just analyse the visible java code and verify
>> that the field is never exposed.
>>
>> As far as I can see, with the current language specification, HotSpot
>> can't safely do this type of optimisation.

>
> Hotspot wouldn't optimize portions of the code that contained idioms
> that forced a heap allocation, but in blocks that don't do the sorts of
> things you mention is most certainly could.
>
> Remember that Hotspot is dynamic, and will de-optimize code at need as
> runtime conditions vary. So an object reference might be optimized to
> register values in one method but not in another, even though it be the
> same object.
>
> If Java were limited to static analysis your objections would carry more
> weight.
>


Dynamic code optimisation is one thing, but this would require dynamic
object layout changes. That is most unlikely in the foreseeable future.
It just isn't practical to back out merging an object into a parent
object. It is possible to do this for the stack because the allocation
has a well defined lifetime and you have located all references.

Mark Thornton
 
Reply With Quote
 
Mark Thornton
Guest
Posts: n/a
 
      05-23-2008
Mark Thornton wrote:
> Lew wrote:
>> Mark Thornton wrote:
>>> Unfortunately the use of == for object identity makes it difficult to
>>> invisibly convert real objects to 'values'. Objects which don't
>>> escape can be held on the stack, but it is harder to merge objects
>>> into others. The fact that reflection can see private fields means
>>> that it isn't possible to just analyse the visible java code and
>>> verify that the field is never exposed.
>>>
>>> As far as I can see, with the current language specification, HotSpot
>>> can't safely do this type of optimisation.

>>
>> Hotspot wouldn't optimize portions of the code that contained idioms
>> that forced a heap allocation, but in blocks that don't do the sorts
>> of things you mention is most certainly could.
>>
>> Remember that Hotspot is dynamic, and will de-optimize code at need as
>> runtime conditions vary. So an object reference might be optimized to
>> register values in one method but not in another, even though it be
>> the same object.
>>
>> If Java were limited to static analysis your objections would carry
>> more weight.
>>

>
> Dynamic code optimisation is one thing, but this would require dynamic
> object layout changes. That is most unlikely in the foreseeable future.
> It just isn't practical to back out merging an object into a parent
> object. It is possible to do this for the stack because the allocation
> has a well defined lifetime and you have located all references.
>
> Mark Thornton


From John Rose (in a comment at
http://blogs.sun.com/jrose/entry/fixnums_in_the_vm)

"The key question is always the deoptimization cost. In this case, it
looks like a full GC could be required to reformat the affected
object(s). It's the Smalltalk "become" primitive, the nasty version
which can change an object's size and layout. I don't think I'm brave
enough to make these transformations automagically. Maybe they would be
justified in the presence of assurances from the user."

You might also look at the comment from Howard Lovatt to the same blog
entry. That refers to the language changes necessary to allow such
optimisations without any fear of having to later deoptimize them.

Mark Thornton
 
Reply With Quote
 
Tom Anderson
Guest
Posts: n/a
 
      05-23-2008
On Thu, 22 May 2008, Lew wrote:

> Tom Anderson wrote:
>> On Thu, 22 May 2008, Kenneth P. Turvey wrote:
>>
>>> I was thinking about this thread a bit and what kind of improvements could
>>> be made to Java to handle math better and one that hadn't been mentioned
>>> yet, that I would very much like to see in Java, is the ability to handle
>>> objects without references.

>>
>> As Lew said, this is something you should leave to the compiler; it's
>> something it can often do if a class is final, and only has final fields.
>> Introducing explicit pass-objects-by-value, as in C, leads to a huge mess
>> of extra complexity.
>>
>> However, there are some fairly unobstrusive changes that could be made to
>> the language that would make it much easier for the compiler to do its
>> magic. The key stumbling block is, i believe, object identity: if a
>> compiler can't prove that an object will never be subjected to an identity
>> test (==) which might succeed, it can't inline/unbox it. I

>
> Which compiler, javac or Hotspot?


Hotspot.

> Hotspot most certainly can determine whether an object is subject to an
> == comparison.


No. Not in all cases. In many useful cases, it can, and can then do
unboxing (provided the handful of other restrictions are met too), but
there will be cases where the escape analysis fails, and it just can't
decide whether it will get =='d.

> It doesn't need to determine that it never is subject to it, only that
> it's not subject to it for a while.


Wrong.

tom

--
You are in a twisty maze of directories, all alike. In front of you is
a broken pipe...
 
Reply With Quote
 
Tom Anderson
Guest
Posts: n/a
 
      05-23-2008
On Fri, 23 May 2008, Mark Thornton wrote:

>> Lew wrote:
>>> Mark Thornton wrote:
>>>
>>>> As far as I can see, with the current language specification, HotSpot
>>>> can't safely do this type of optimisation.
>>>
>>> If Java were limited to static analysis your objections would carry more
>>> weight.

>
> From John Rose (in a comment at
> http://blogs.sun.com/jrose/entry/fixnums_in_the_vm)
>
> "The key question is always the deoptimization cost. In this case, it
> looks like a full GC could be required to reformat the affected
> object(s). It's the Smalltalk "become" primitive, the nasty version
> which can change an object's size and layout. I don't think I'm brave
> enough to make these transformations automagically. Maybe they would be
> justified in the presence of assurances from the user."


Bingo.

> You might also look at the comment from Howard Lovatt to the same blog
> entry. That refers to the language changes necessary to allow such
> optimisations without any fear of having to later deoptimize them.


You mean the link to:

http://bugs.sun.com/bugdatabase/view...bug_id=4617197

? He covers all the important things, but also a lot of crazy ideas.

tom

--
You are in a twisty maze of directories, all alike. In front of you is
a broken pipe...
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      06-22-2008
Kenneth P. Turvey wrote:
> I really don't think it would take much in terms of language changes to
> really make Java a good language for these applications. I don't know
> why Sun has decided not to target these applications.


For good and for worse: there is more money in a bank application
than in a simulator that will discover how the universe started.

Arne

 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      06-22-2008
Mark Thornton wrote:
> Unfortunately the use of == for object identity makes it difficult to
> invisibly convert real objects to 'values'. Objects which don't escape
> can be held on the stack, but it is harder to merge objects into others.


C# took a different approach from Java. And it seems to work
pretty well.

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prepped and ready to mod. Ludnix Case Modding 137 10-09-2005 11:04 AM
OT: Number Nine, Number Nine, Number Nine Frisbee MCSE 37 09-26-2005 04:06 PM
Hiper Type-R 580W SLI Ready Modular Power Supply Review Silverstrand Front Page News 0 09-03-2005 01:45 PM
FireFox & Thunderbird v1.0.6 ready for Download Old Gringo Firefox 6 07-24-2005 10:53 PM
Firefox...not ready for prime time. Jim L Firefox 21 02-17-2005 02:05 PM



Advertisments