Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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 14136 times)
0 Members and 1 Guest are viewing this topic.
Offline krausest

Junior Member


Exp: 15 years


I love YaBB 1G - SP1!


« Reply #30 - Posted 2004-11-16 05:51:39 »

The first Mustang builds are available. Is something that you mentioned already contained in those builds?
http://j2se.dev.java.net/
Offline Azeem Jiva

Junior Member




Java VM Engineer, Sun Microsystems


« Reply #31 - Posted 2004-11-16 13:57:42 »

That's amazing, you found this out before I did!  Anyway yeah that would be where all my changes went to.  B12 has everything except for the Math.abs() stuff, that's in B13.  Enjoy Smiley
Offline ChrisRijk

Senior Newbie




Optimise or Die


« Reply #32 - Posted 2004-11-16 15:51:19 »

Some quick benchmarking with b12 (compared to 5.0 final) on a Mandelbrot benchmark I have which uses Math.log:

5.0 client - 1219 ms
5.0 server - 906 ms
6.0 client - 1203 ms
6.0 server - 562 ms

So client is basically the same while server is about 60% faster (with this particular example).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Azeem Jiva

Junior Member




Java VM Engineer, Sun Microsystems


« Reply #33 - Posted 2004-11-16 15:56:30 »

Yeah, LN and LOG10 are the only math intrinsics that are not in Client but are in Server.  I probably should go back and add them
Offline Azeem Jiva

Junior Member




Java VM Engineer, Sun Microsystems


« Reply #34 - Posted 2004-11-16 16:25:52 »

Quote

So client is basically the same while server is about 60% faster (with this particular example).


Actually to be picky, its 38% faster 1 - 562/906 = .38

Smiley
Offline Azeem Jiva

Junior Member




Java VM Engineer, Sun Microsystems


« Reply #35 - Posted 2004-11-17 00:58:04 »

Ok I've got LN and LOG10 intrinsified in client as well, should be available in b14 or b15.
Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #36 - Posted 2004-11-17 08:10:18 »

Is escape analysis going to make it into 6.0? Sure would like to see an end to some of the crappy programming practises I have to employ :/

Cas Smiley

Offline Seb

Senior Newbie




import com.acme.Bomb;


« Reply #37 - Posted 2004-11-17 20:51:38 »

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

Cas Smiley


Hi Cas, you might be interested in visiting the Mustang Forums, they are also pushing for structs there maskerading under extprim or some such.

Seb

Offline Seb

Senior Newbie




import com.acme.Bomb;


« Reply #38 - Posted 2004-11-17 20:56:24 »

Quote
The first Mustang builds are available. Is something that you mentioned already contained in those builds?
http://j2se.dev.java.net/


Here's the changelog for build 12:

http://forums.java.net/jive/thread.jspa?threadID=58&tstart=105

Seb

Offline shawnkendall

Senior Member





« Reply #39 - Posted 2004-11-19 01:34:43 »

Well, Structs have made it into the Top 10 RFEs, and still no REPLY from Sun.

Structs crosspost:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Offtopic;action=display;num=1055068121;start=30#36

Shawn Kendall
Cosmic Interactive, LLC
http://www.facebook.com/BermudaDash
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #40 - Posted 2004-11-19 09:38:56 »

I fear that Structs are a hot potato. Lots of people have all sorts of different solutions to the same problem, and my proposal doesn't make most of them happy. I just want fast memory mapped interfaces between ByteBuffers and Java Objects. Mostly everybody else wants stuff like LWOs for maths and such. The issue is clouded because people like to think there is some overlap and that if there isn't overlap then there should be or it'll make everyone confused. IMHO my Structs RFE has nothing to do with LWOs and should be kept completely separate.

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

Cas Smiley

Offline Linuxhippy

Senior Member


Medals: 1


Java games rock!


« Reply #41 - Posted 2004-11-19 09:57:53 »

Structs would be cool SOMETIMES, but I think they are as useless as generics. A cast more or less is nothing compared with the added complexity of the java-language :-(

However I do not want to start another flame so I will ask something completly different ;-)

What really would fascenate me would be something called like "hotspot-performance guide" where some tipps are given to the developers with different toppics.
This should in general not concentrate onto API-stuff, it should focus much more on howto write java that can be generated to efficient bytecode.
Sections like FP-calculations (when SSE will be used..), int-calculations, loops, switch-statements and so on.
Offline Mark Thornton

Senior Member





« Reply #42 - Posted 2004-11-19 11:47:29 »

Quote
I just want fast memory mapped interfaces between ByteBuffers and Java Objects.

Your original proposal includes a language change and that is what most people see when they look at that RFE. This opened the can of worms relating to light weight objects, and it is hard to put the lid back on.
Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #43 - Posted 2004-11-19 13:20:16 »

Unfortunately I can't edit the damned thing :/

Cas Smiley

Offline Azeem Jiva

Junior Member




Java VM Engineer, Sun Microsystems


« Reply #44 - Posted 2004-11-19 13:46:01 »

Quote

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

Cas Smiley


I'm a peon here, nobody will listen to what I say.  I tried to talk to Graham about structs and he said "Sorry too specialized can't do it".  Basically I doubt this will happen, unless several large corporations get together and ask for ir through the JCP.
Offline rreyelts

Junior Member




There is nothing Nu under the sun


« Reply #45 - Posted 2004-11-19 14:47:02 »

Quote
I'm a peon here, nobody will listen to what I say.  I tried to talk to Graham about structs and he said "Sorry too specialized can't do it".  Basically I doubt this will happen, unless several large corporations get together and ask for ir through the JCP.

How difficult do you think it would be to implement the change? If some of us got together and modded the 1.5 JVM to support structs, would there be a good chance that you could get those changes accepted into a new release? (Let's assume no language changes). We could provide some sample benchmarks that would demonstrate the performance improvements.

The only reason that this feature appears "too specialized", is because people have generally avoided using Java for high-performance tasks. Now that more people are attempting to use Java for those kinds of applications, they're bumping up against real problems.

God bless,
-Toby Reyelts

About me: http://jroller.com/page/rreyelts
Jace - Easier JNI: http://jace.reyelts.com/jace
Retroweaver - Compile on JDK1.5, and deploy on 1.4: http://retroweaver.sf.net.
Offline Seb

Senior Newbie




import com.acme.Bomb;


« Reply #46 - Posted 2004-11-19 14:58:28 »

Darn, someone should move the structs thread over at Off Topic into Performance Tuning.

Anyway, I think we need someone to write an article detailing all the different reasons different people propose structs, and compare the proposed solutions.

The article might conclude structs won't be the best solution to some of these performance problems, and escape analysis will do there. The article will explain to those affected why escape analysis is better in these cases and why structs will be better in other cases.

Then it will go on to propose a struct design that solves all problems not solved by escape analysis and perhaps by some other means.

This will hopefully unite developers into supporting this common design (well, I did say hopefully) and form the basis of a serious community backed design to present to Sun.

Anyone up for it? Write the article I mean.

Seb


Offline Mark Thornton

Senior Member





« Reply #47 - Posted 2004-11-19 15:33:21 »

Forgetting for a moment various alternative uses of structs, what is the minimum needed to get reasonable performance for IO use?

1  
2  
3  
4  
5  
void putStruct(ByteBuffer b, int offset, MyData z) {
b.putShort(offset, z.a);
b.putInt(offset+2, z.b);
b.putInt(offset+6, z.c);
}


Given code like this, would it not suffice to optimise the bounds checks and assignments involved in those calls. Pseudo code like this

1  
2  
3  
4  
5  
6  
7  
8  
if (b.isNativeOrdering && b.limit >= offset+10) {
   ((short*)(b.bytes+offset)) = z.a;
   ((int*)(b.bytes+offset+2)) = z.b;
   ((int*)(b.bytes+offset+6)) = z.c;
}
else {
   // do it the hard way ...
}


Then if this code appeared in a loop just do the usual strength reduction and unrolling as well.
Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #48 - Posted 2004-11-19 16:20:58 »

I'm sure something along these lines could be achieved using reflection, the new metadata tags in 1.5, a modified classloader and a dynamic bytecode generator, using the sun.misc.Unsafe class...

Cas Smiley

Offline Jeff

JGO Coder




Got any cats?


« Reply #49 - Posted 2004-11-22 01:25:25 »

Quote
Darn, someone should move the structs thread over at Off Topic into Performance Tuning.

Anyway, I think we need someone to write an article detailing all the different reasons different people propose structs, and compare the proposed solutions.



To be complete it should also research and present clearly the arguments given for why structs haven't been done to date.  I'm no expert but I believe their are some serious VM complications and perhapse some security problems that this would introduce due to java's late binding.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Seb

Senior Newbie




import com.acme.Bomb;


« Reply #50 - Posted 2004-11-22 23:17:51 »

Hi,

I started a thread over at JavaLobby about the different suggestions on how to implement structs.

Why JavaLobby? Well it's my job, I'm an editor there Wink, but most importantly because I think it a great location to get input from the whole community on this particular matter that goes beyond the development of games so that all ideas are put on the table and other people are exposed to the possibility.

Perhaps get a serious and complete proposal going.

Seb

Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #51 - Posted 2004-11-23 09:00:46 »

Can't reply to it Sad
"You are not authorized to create a new user account."

Cas Smiley

Offline Seb

Senior Newbie




import com.acme.Bomb;


« Reply #52 - Posted 2004-11-23 12:03:57 »

Hi Cas,

In Rick's own words: "we have been having a mysterious problem with connections bombing [...] should be fine now".  

Give it another try and let me know how it goes. Thanks,

Seb

Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #53 - Posted 2004-11-23 12:30:36 »

Works now.

Cas Smiley

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #54 - Posted 2004-11-23 13:20:51 »

I threw my 2 cents worth into the discussion with this response. Sorry for not cross-posting, but I'm feeling lazy. Grin

Edit: Ah, hell. I guess I'm not that lazy. Here it is:

You're looking for something like this?
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
//File: Test.struct
//Purpose: Demonstrates the Struct class type

package com.mypackage;

public struct TestStruct output Bean order Big
{
    byte b;
    short s;
    int i;
    long l;
   
    float f;
    double d;
   
    double[3] vertex;
    int[i] texture;
}


Which then outputs a java file like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
package com.mypackage;

import java.nio.*;

public class TestStruct
{
    private ByteBuffer buffer;
    private boolean hasArray;

    private int[] positions = new int[8];

    public TestStruct(ByteBuffer buffer)
    {
        ByteBuffer temp;

        int position = 0;

        this.buffer = buffer;
        this.hasArray = buffer.hasArray();
        this.positions[0] = position;
        buffer.position(buffer.position()+1);
        position += 1;

        this.positions[1] = position;
        buffer.position(buffer.position()+2);
        position += 2;

        this.positions[2] = position;
        buffer.position(buffer.position()+4);
        position += 4;

        this.positions[3] = position;
        buffer.position(buffer.position()+8);
        position += 8;

        this.positions[4] = position;
        buffer.position(buffer.position()+4);
        position += 4;

        this.positions[5] = position;
        buffer.position(buffer.position()+8);
        position += 8;

        this.positions[6] = position;
        temp = buffer.slice();
        temp.limit(3);
        this.vertex = temp.asDoubleBuffer().array();
        position += 3 * 8;

        this.positions[7] = position;
        temp = buffer.slice();
        temp.limit(getI() * 4);
        this.texture = temp.asIntBuffer().array();
        position += (int)getI() * 4;

    }

    public byte getB()
    {
        return buffer.getByte(positions[0]);
    }

    public void setB(byte b)
    {
        return buffer.setByte(positions[0], b);
    }

    public short getS()
    {
        return buffer.getShort(positions[1]);
    }

    public void setS(short s)
    {
        buffer.setShort(positions[1], s);
    }

    //More getters and setters here
}


Here's the "Struct" format:
1  
2  
3  
4  
5  
6  
package [packagename];

public struct [ClassName] [output Bean|Struct] [order Little|Big]
{
    [primitive] [name];
}


Bean vs. Struct was an alternate method of accessing the data I was working on. Bean is the default. Order controls the little or big endianess of the ByteBuffer. To convert the struct from C to Java, you can simply wrap the structure in a ByteBuffer and pass it to the constructor of your Java "Struct". The current code requires that the buffer positions be predictable, although I was spending some time working out how they could be make dynamic.

I was working on this in response to Caspian Prince's desire for a Struct feature. The way I see it, there's no need to change the Java language when a preprocessor can convert the structures just fine. I stopped working on the project when I realized that J.A.D.E. already had a similar structure concept.

If anyone wants the code I've done, I could probably send it to you. Just shoot me an email. Smiley

Java Game Console Project
Last Journal Entry: 12/17/04
Offline princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #55 - Posted 2004-11-23 13:50:30 »

The most significant problem here is that you are a) still referencing individual fields via getters and setters and not directly in-situ and b) still having to do individual bounds checks on each field access.

In order to do something like vec3f.x += 1.0f; your idea would require a bounds check, a read, an add, a bounds check, and a write. If you subsequently do lots and lots of tweaks on the same struct you'll be doing lots and lots of bounds checks. They only need to be checked once, when the struct is placed in position in the buffer.

Cas Smiley

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #56 - Posted 2004-11-23 13:54:57 »

Indeed. The (as of yet undeveloped) Struct version of the class was intended to sovle that by producing a class with public members that could be directly modified. The members could then be copied back into the ByteBuffer on a "commit()" or "getByteBuffer()" call. It wouldn't eliminate the issue, but it would reduce it. Smiley

Java Game Console Project
Last Journal Entry: 12/17/04
Offline rreyelts

Junior Member




There is nothing Nu under the sun


« Reply #57 - Posted 2004-11-23 13:59:05 »

Quote
The way I see it, there's no need to change the Java language when a preprocessor can convert the structures just fine.

Umm... ok. So you didn't change the Java language, but you invented a new language which targets Java. Your new language only has half-assed language support through the existing Java tools (e.g. editors and debuggers). In general, code generation suffers several drawbacks, and it's why bytecode rewriting has become so popular.

Given all that, the simplest and most effective change you could make to your application is to change it to use annotations and APT. You'd still be generating code, but at least it would mitigate some of the drawbacks of your current solution.

God bless,
-Toby Reyelts

*made some clarifications*

About me: http://jroller.com/page/rreyelts
Jace - Easier JNI: http://jace.reyelts.com/jace
Retroweaver - Compile on JDK1.5, and deploy on 1.4: http://retroweaver.sf.net.
Offline Seb

Senior Newbie




import com.acme.Bomb;


« Reply #58 - Posted 2004-11-23 15:05:27 »

Allright, I just posted at JL a summary of most things said so far including this thread.

However I'm not cross-posting as my intention is to have you reply over there so that the broader community gets to read and participate, not just us guys over at the gaming forums. Thanks,

Seb

Offline Chris Duesing

Senior Newbie





« Reply #59 - Posted 2004-11-23 20:40:32 »

Link didnt work for me, try this:

http://www.javalobby.org/forums/thread.jspa?threadID=15807&messageID=91818608#91818608
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.

Riven (12 views)
2014-07-29 18:09:19

Riven (8 views)
2014-07-29 18:08:52

Dwinin (9 views)
2014-07-29 10:59:34

E.R. Fleming (26 views)
2014-07-29 03:07:13

E.R. Fleming (10 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (27 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!