Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (492)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 [3] 4
  ignore  |  Print  
  New VM performance improvements  (Read 14566 times)
0 Members and 1 Guest are viewing this topic.
Offline Seb

Senior Newbie




import com.acme.Bomb;


« Reply #60 - Posted 2004-11-23 19:55:29 »

Use the link Chris provided.

A note to the site admins: When I went back to edit my post I saw that the link is correctly written in the url tag, I left it lke that. Some springs might be loose when generating the page I guess.

Seb

Offline kcpeppe

Senior Newbie




Type safety is for the weak


« Reply #61 - Posted 2004-11-26 05:55:11 »

Quote
I fear that Structs are a hot potato.

But that, in a nutshell, is why I think no-one has replied yet. Not even Azeem...

Cas Smiley


I see no use for structs in an OO based langauge. Structs are data with no behavior. Where do you put the behavior? How do you control the state?

I think what you are really asking for is the ability to use the shape of an object to define structure with-in a buffer or mmap'ed area of memory. This does not require a change in Java to achieve.

I am currently activily arguing against ANY changes to the Java language specification BEFORE we fully understand the implications of the change. I'm not interested in a pro/anti generics descission as this is not the forum for it but.... I will use it as an example where the JCP jumped the gun in dropping in a flawed version of a change to the language and now that we have it, it is practically impossible to go back. I would suggest that changing a language is not something that the average programmer has enough knowledge to offer an expert opinion on how to extend a language. I, myself, do not claim to have enough knowledge to offer an expert opinion on how to extend any language. That said, what I do know is that more language features = more choice = more complexity = more problems. The thing that is wonderful about Java is that it does offer a syntax that approaches Smalltalk in simplicity but offers syntax and concepts that make is less foreign to those that need functional structures in order to  work.


KEEP JAVA SIMPLE!  
Cool
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #62 - Posted 2004-11-26 08:17:40 »

You probably don't see a use for ints then either...

I wish I hadn't called them Structs now, because they are so not like C-structs at all.

Quote
I see no use for structs in an OO based langauge. Structs are data with no behavior. Where do you put the behavior? How do you control the state?
A struct in C++ is just a class like any other with every member declared public. That's not what I'm after, of course.

Quote

I think what you are really asking for is the ability to use the shape of an object to define structure with-in a buffer or mmap'ed area of memory. This does not require a change in Java to achieve.

That's dead right, but I am unable to tweak the RFE. What I want is a VM semantic. It can be implemented in pure bytecode by altering the system classloader to generate bytecode on the fly, or the VM can intrinsify it when it spots the markers, eg. extending the abstract class java.nio.Struct.

In particular I don't want to have to use getXXX()/setXXX() to access fields in the struct if I don't want to.

Quote

KEEP JAVA SIMPLE!  

When you see the hairy code we have to write to do OpenGL you'll understand. The worst bit is, even though it's hairy, it's still 50% of the speed of the C version Sad

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kcpeppe

Senior Newbie




Type safety is for the weak


« Reply #63 - Posted 2004-11-26 13:19:16 »

Quote
You probably don't see a use for ints then either...

I wish I hadn't called them Structs now, because they are so not like C-structs at all.


Well, unless I've misunderstood what I've seen... these structs to look very C like in that there is space for shape but now for methods. As for getters/setters, I guess you could opt for public instance variables. The problem that I see is that public runs counter to encapsulation. That said, we do sometimes need to violate encapsulation for performance



Quote

When you see the hairy code we have to write to do OpenGL you'll understand. The worst bit is, even though it's hairy, it's still 50% of the speed of the C version Sad


Well, when I think back on some of the bit twiddling that I needed to do, if was one instance were OO just didn't seem to fit or at least I couldn't seems to satisfy the demands of OO and performance. Needless to say that performance needed to win and it did and OO was tossed on that particular effort. When we tossed OO, we also opted for C and FORTRAN in favor of Smalltalk (the OO choice at the time). For some reason, I just can't see myself choosing Java over C in the same situation and I am an OO bigot  Grin
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #64 - Posted 2004-11-26 13:36:07 »

I'm an OO bigot too Smiley

We don't need member variables to be public, we need them to be accessible without get/set for the purposes of readability within the Struct's methods itself.

Classic example: Vector3f.

Cas Smiley

Offline kcpeppe

Senior Newbie




Type safety is for the weak


« Reply #65 - Posted 2004-11-26 14:05:13 »

Quote
I don't suppose you'd care to champion Structs with me?

Cas Smiley


In a nutshell... not as they are currently defined. But what I would champion with you is the ability of NIO to paste objects into a buffer giving that buffer structure. This is a low level feature that does have some interesting possibilities.
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #66 - Posted 2004-11-26 16:30:27 »

That's exactly what I want. A way to map a Java object onto a byte buffer. No more, no less.

Cas Smiley

Offline kcpeppe

Senior Newbie




Type safety is for the weak


« Reply #67 - Posted 2004-11-26 17:09:33 »

Quote
I'm an OO bigot too Smiley

We don't need member variables to be public, we need them to be accessible without get/set



humm, not public yet accessible.... you don't mind if I don't point out the contradiction on that statement will you??? ooops, I already did  Shocked

and oh, not being 'merican.. I almost forgot, happy turkey day
Offline Malohkan

Senior Member




while (true) System.out.println("WOO!!!!");


« Reply #68 - Posted 2004-11-27 01:55:58 »

HAAAAPPPYYY TURKEY DAY!!!! Smiley

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #69 - Posted 2004-11-27 10:55:58 »

Poor things. And they're so ugly, too Sad

After you've been doing OO for a very long time you begin to realise really what OO is all about. The big wet-fish-in-the-face surprise is that the dot operator and public keyword are actually there for a reason! Who'd have thought it? Besides, I want my members private as usual, so I can still write methods that go "return Math.sqrt(x * x + y * y);"

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kcpeppe

Senior Newbie




Type safety is for the weak


« Reply #70 - Posted 2004-11-28 11:59:25 »

Quote
Poor things. And they're so ugly, too Sad

After you've been doing OO for a very long time you begin to realise really what OO is all about. The big wet-fish-in-the-face surprise is that the dot operator


dots I could do without.... well for method calls anyways. Hotspot should [bold]ALWAYS[bold] inline a getter which should most likely be private 99% of the time anyways. Ask, don't tell


Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #71 - Posted 2004-11-28 12:56:37 »

Quote
Hotspot should [bold]ALWAYS[bold] inline a getter...


And yet often it can't.

According to some message that I just read on the Mac java-dev mailing list basic classes like ArrayList can't have the set(), get() or add() methods inlined properly due to the way the bounds check works. (Something to do with the way the out of bounds exception is thrown.)

Offline kcpeppe

Senior Newbie




Type safety is for the weak


« Reply #72 - Posted 2004-11-28 21:06:20 »

Quote


And yet often it can't.

According to some message that I just read on the Mac java-dev mailing list basic classes like ArrayList can't have the set(), get() or add() methods inlined properly due to the way the bounds check works. (Something to do with the way the out of bounds exception is thrown.)



Man, ArrayList OWNS it's iterator... you'd think bounds checking would be unnecessary in that situation. I guess it's an either on or off check :|
Offline Spasi
« Reply #73 - Posted 2005-02-02 13:53:31 »

Quote
I'm open for suggestions to other improvements that might help.


How about a new "sincos" method? That is, a method that returns both sine and cosine of the same angle. Such a method is useful in many situations (for example quaternion calculation). The alternative is to call Math.sin and Math.cos, but a single method would likely optimize the calculation somehow.

While searching for a better solution to achieve this, I found a piece of code that results in a very good approximation:

1  
2  
3  
4  
5  
float tan = (float)Math.tan(Math.toRadians(rot * 0.5));
float tanSQ = tan * tan;
float tanRCP = 1.0f + tanSQ;
float sin = 2.0f * tan / tanRCP;
float cos = (1.0f - tanSQ) / tanRCP;


For reference, the above code (after VM optimizations) is ~30% faster than the equivalent implementation using Math.sin and Math.cos.

It isn't something we can't live without, but after seeing what was added to Math in 5.0, it would be nice to have in 6.0.
Offline Azeem Jiva

Junior Member




Java VM Engineer, Sun Microsystems


« Reply #74 - Posted 2005-02-02 18:56:29 »

Quote


How about a new "sincos" method? That is, a method that returns both sine and cosine of the same angle. Such a method is useful in many situations (for example quaternion calculation). The alternative is to call Math.sin and Math.cos, but a single method would likely optimize the calculation somehow.



Except that as a whole the sincos doesn't add anything to the libraries.  Not to mention that x86 would be the only platform to gain from this (having the fsincos instrution).  Its just not very practical and way too specialized to have a "sincos" method.
Offline Raghar

Junior Member




Ue ni taete 'ru hitomi ni kono mi wa dou utsuru


« Reply #75 - Posted 2005-02-02 20:42:11 »

New improvements?
Of course thats easy.

XCHNG instruction for swapping without using a temporally variable.
This means XCHNG int int
or XCHNG float, float
I think XCHNG Object, Object would work too, but let it be introduced on primitives first.

GC impovements:
If I know I would call some method that would be a really object generation/throwing away intensive, it will be nice to give some hint to GC. Like GC.hint(SOR_EXPECTED, GC_FRAME, 1); //small object release
GC.hint(BIGGOR_EXPECTED, GC_FRAME, 1); //bigg object release
GC.hint(BIGGOR_EXPECTED, GC_NEXT_METHOD, CLEAN_INSIDE) //This means next method would create a lot of garbage and cleans before return would be much better than swapping it out.
And of course the favorite:
GC.clean(long) //Clean it now. If you want to do any cleaning, you'd have long nanosecond (int millisecond). Return imediately if not interested.

Releasing of memory.
It would be nice if JVM release some memory after 5 minutes when it had around 60 MB free, and unused for long time. Actually when you have allocated 800MB and swapped on 2GB swap it doesn't matter too much, but I might like be able to run 3 of these programs, just for testing, and then it could (will?) create problems.


And a few questions:

Are you using MMX register as a scratchpad? I mean in a PS2 way. 4096 Bytes againts 64 Bytes is a big difference, but it's handy sometimes.

How effective is arraybound test elimination? For example if you had
image[a] + image[a+1] + image [a+2];
image[a - 1] + image[a] + image [a+2];
How many times would it check for out of bounds access?
Offline phazer

Junior Member




Come get some


« Reply #76 - Posted 2005-02-03 06:15:53 »

Quote
New improvements?
Of course thats easy.

XCHNG instruction for swapping without using a temporally variable.
This means XCHNG int int
or XCHNG float, float
I think XCHNG Object, Object would work too, but let it be introduced on primitives first.


How do you know it's not already used?

Quote

GC impovements:
If I know I would call some method that would be a really object generation/throwing away intensive, it will be nice to give some hint to GC. Like GC.hint(SOR_EXPECTED, GC_FRAME, 1); //small object release
GC.hint(BIGGOR_EXPECTED, GC_FRAME, 1); //bigg object release
GC.hint(BIGGOR_EXPECTED, GC_NEXT_METHOD, CLEAN_INSIDE) //This means next method would create a lot of garbage and cleans before return would be much better than swapping it out.
And of course the favorite:
GC.clean(long) //Clean it now. If you want to do any cleaning, you'd have long nanosecond (int millisecond). Return imediately if not interested.


Worthless. Telling the GC what to do will not improve performance.

Quote

Releasing of memory.
It would be nice if JVM release some memory after 5 minutes when it had around 60 MB free, and unused for long time. Actually when you have allocated 800MB and swapped on 2GB swap it doesn't matter too much, but I might like be able to run 3 of these programs, just for testing, and then it could (will?) create problems.


I believe Java 5 can release memory back to the OS. Not sure though.

Offline Deadcow

Senior Newbie




Back from beyond ... Moo!


« Reply #77 - Posted 2005-02-03 10:04:01 »

What about adding "clamp" methods to Math ?

1  
2  
3  
4  
5  
int clamp( int lower_bound, int value, int upper_bound );

// equivalent to

int max( lower_bound, min( upper_bound, value ));


And the same for byte, short, long, float, double of course.
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #78 - Posted 2005-02-03 10:20:59 »

Azeem, that's a poor reason for not implementing sincos. If sincos is an instruction supported on 90% of the world's computers then you may as well add it for those that can gain performance from it. For the remaining machines, it won't make any difference.

It may be a specialist function but when it comes to performance tuning we are exactly talking about tuning for specialists.

Likewise the clamp() function - maybe not relevant today, but one day maybe intrinsifiable.

And so on, right on to full matrix operations.

Cas Smiley

Offline Spasi
« Reply #79 - Posted 2005-02-03 12:03:24 »

Hehe, I didn't know an fsincos instruction exists, it just seemed logical to me that a low-level sincos implementation could be optimized. Actually, the existence of such an instruction somewhat proves its usefulness.
Offline Deadcow

Senior Newbie




Back from beyond ... Moo!


« Reply #80 - Posted 2005-02-03 13:05:37 »

Operations on streams can be very cool too ( and subject to massive optimizations using MMX, 3DNow, SSE, SSE2, SSE3, etc ).

1  
2  
3  
4  
5  
6  
void add( int value, int[] stream, int offset, int length );
void mul( float factor, float[] stream, int offset, int length );
void xor( short mask, short[] stream, int offset, int length );
void lshift( int amount, int[] stream, int offset, int length );
void clamp( byte lbound, byte ubound, byte[] stream, int offset, int length );
...
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #81 - Posted 2005-02-03 14:19:06 »

That's why we need an SSE class that can be intrinsified on platforms that support it natively or simply implemented in tight machine code otherwise. We had something on those lines in LWJGL in the early days but, er, as we didn't know shit from shinobi we took it out Wink

Cas Smiley

Offline c_lilian

Senior Member


Projects: 1


Java games will probably rock someday...


« Reply #82 - Posted 2005-02-03 14:48:27 »

I like the idea of an SSE library, may be someone here with strong competences could start a new project on java.net...

Unfortunately, it won't be me, as i don't feel strong enough in that domain.

I like the write once paradigm of java, but there are times where it's faster to develop a multiplatform performance library than to rely on hotspot optimizations. For application using JO/LWJ GL , which already requiere .dll and .so to be bundled with, another tiny native lib compatible with the same platform base would not be harmful...

Lilian

Offline Azeem Jiva

Junior Member




Java VM Engineer, Sun Microsystems


« Reply #83 - Posted 2005-02-03 15:31:16 »

Quote
Azeem, that's a poor reason for not implementing sincos. If sincos is an instruction supported on 90% of the world's computers then you may as well add it for those that can gain performance from it. For the remaining machines, it won't make any difference.


Except I have no control over what can go into the libraries.  I could file a bug and hope somebody over there would find it interesting enough to add a Math.sincos() and then I could intrinsify it.  Or alternatively I could add a very contrived match that checked for a sin and cos on the same variable right next to each other.  Hmmm actually that might not be hard, but its very specialized.  

Oh and Ragher check out System.gc()
Smiley


Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #84 - Posted 2005-02-03 17:22:34 »

Quote
Hi guys,
 I'm open for suggestions to other improvements that might help.  


If you're still interested, email me on adam at grexengine.com.

I've been gathering complaints from C++ games devs, and whittling out the few that are dependent on fundamental ops that java lacks. Personally, I'm not sure how valid many of them are - I'm happy to discuss them with you via email, and then go request more info from the individual devs wherever you want more detail / evidence / etc.

malloc will be first against the wall when the revolution comes...
Offline Raghar

Junior Member




Ue ni taete 'ru hitomi ni kono mi wa dou utsuru


« Reply #85 - Posted 2005-02-03 22:10:19 »


Quote
Oh and Ragher check out System.gc()  


One size fits them all...
Used it and think it could be much better. Especially if it would look for methods named clean.

BTW where is System.gc(long)?

Deadcow:
Quote
What about adding "clamp" methods to Math ?


I did it already. It's in my image library, with few conversion rutines like RGBtoR ... and some others.

Clamp is programming function not math function. If you'd like to add something to the math it could be FFT, mem intensive FFT, DCT, IDCT, matrix operations, and possibly something helpful.


Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #86 - Posted 2005-02-04 07:55:11 »

I bet that once escape analysis comes along that no-one will be worried about GC any more.

Cas Smiley

Offline Deadcow

Senior Newbie




Back from beyond ... Moo!


« Reply #87 - Posted 2005-02-04 08:54:37 »

Quote


Clamp is programming function not math function. If you'd like to add something to the math it could be FFT, mem intensive FFT, DCT, IDCT, matrix operations, and possibly something helpful.



Neither max nor min are actually "math functions" and they can be relpaced by
1  
2  
3  
4  
// max
a > b ? a : b;
// min
a > b ? b : a;


They exist for sake of clarity ( and possible optimization ), as clamp should.
Offline Azeem Jiva

Junior Member




Java VM Engineer, Sun Microsystems


« Reply #88 - Posted 2005-02-04 15:08:28 »

Quote


Neither max nor min are actually "math functions" and they can be relpaced by
1  
2  
3  
4  
// max
a > b ? a : b;
// min
a > b ? b : a;


They exist for sake of clarity ( and possible optimization ), as clamp should.


Actually they are:

1  
2  
return (a <= b) ? a : b;
return (a >= b) ? a : b;


And in the case of doubles there is some NaN handling and what not.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #89 - Posted 2005-02-05 18:38:40 »

If we are talking about new APIs in the Math area, or just certain calculations to recognise and optimize... something that converts between polar coordinates and cartesian coordinates would be useful, since the current Math.tan methods only return part of the answer, but usually have calculated more...  I mean the angle and radius are known internally, but only the angle is returned, and so a duplicate square root calculation might happen.  Stuff like that can help in various 2D and 3D games.
There was a discussion about this on Apple's performance tuning email lists recently that I found interesting.

Re: the clamping functions...

When using software loops to blend RGB image data (with Alpha), vector instructions would offer a HUGE advantage.  Is there any way the compiler could recognize those types of loops?  Though, I must admit it isn't worth it at all if the graphics processor can be used to accelerate the operation entirely.. so it is probably best for the Java2D guys to take care of that at a higher level.

So I guess the general purpose API to gain access to vector operations like what Cas was saying is really more important.

Pages: 1 2 [3] 4
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (33 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (40 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (37 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!