Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Performance Tuning / Re: New C1 in Mustang b59 on: 2005-11-11 16:51:40
As a side note, this RFE was pointed out on JavaLobby:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6180872

Quote
As part of the tiered compilation work for Mustang, the HotSpot client compiler needs to be enhanced to update the methodDataOop profiling counters used by the server compiler to generate higher-quality code.

This was also part of b59 of Mustang.

So, some parts of tiered compilation are already in?

Any chance you can comment further on this, Azeem...?
2  Game Development / Performance Tuning / Re: CPU counters via JNI --> post CODE on: 2005-01-03 21:16:58
Quote
could you please post your solaris code? i would really appreciate.


You got Solaris, or want to adapt the code? btw, if you do have some non trivial suggestions/improvements, I'd appreciate you posting them back or something.

javacpc.c
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  
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/time.h>
#include <inttypes.h>
#include <libcpc.h>
#include <errno.h>

#include <jni.h>
#include "CPC.h"

// http://developers.sun.com/solaris/articles/optimizing_apps.html
// http://developers.sun.com/solaris/articles/hardware_counters.html

cpc_event_t *before, *after;
long long *timings;
hrtime_t start;

cpc_event_t event;
int cpuver;
const char *setting;

JNIEXPORT void JNICALL Java_CPC_initCPC(JNIEnv *env, jclass obj) {
  before = (cpc_event_t *)calloc(0, sizeof(cpc_event_t));
  after = (cpc_event_t *)calloc(0, sizeof(cpc_event_t));
  timings = (long long *)calloc(0, sizeof(long long));
}

JNIEXPORT jint JNICALL Java_CPC_setupCPC(JNIEnv *env, jclass obj, jstring events, jint size) {
  free(before);
  free(after);
  free(timings);
  before = (cpc_event_t *)calloc(size, sizeof(cpc_event_t));
  after = (cpc_event_t *)calloc(size, sizeof(cpc_event_t));
  timings = (long long *)calloc(size, sizeof(long long));

  setting = (*env)->GetStringUTFChars(env, events, 0);

  if ((cpuver = cpc_getcpuver()) == -1) {
    printf("no performance counters\n");
    return 1;
  }
  printf("hardware identifier %d\n", cpuver);

  if (cpc_strtoevent(cpuver, setting, &event) != 0) {
    printf("ev : cannot measure %s\n", setting);
    return 2;
  }

  setting = cpc_eventtostr(&event);
  if (cpc_bind_event(&event,0) == -1) {
    printf("cannot bind lwp %d %s\n", _lwp_self(),strerror(errno));
    return 3;
  }
  return 0;
}

JNIEXPORT void JNICALL Java_CPC_recordBefore(JNIEnv *env, jclass obj, jint index) {
  start = gethrtime();
  cpc_take_sample(&before[index]);
}

JNIEXPORT void JNICALL Java_CPC_recordAfter(JNIEnv *env, jclass obj, jint index) {
  cpc_take_sample(&after[index]);
  timings[index] = gethrtime() - start;
}

JNIEXPORT jlong JNICALL Java_CPC_getSample(JNIEnv *env, jclass obj, jint index, jint event) {
  return after[index].ce_pic[event] - before[index].ce_pic[event];
}

JNIEXPORT jlong JNICALL Java_CPC_getNanos(JNIEnv *env, jclass obj, jint index) {
 return timings[index];
}



CPC.java
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  
public class CPC {
    private static String eventSpec = null;
    private static int samplePairSize = 0;
    private static boolean setupOkay = false;
    private static int sampleIndex = 0;

    static {
        try {
            System.loadLibrary("javacpc");
            initCPC();
        } catch (Exception E) {
            throw new Error(E);
        }
    }

    public static boolean setup(String events, int size) {
        eventSpec = events;
        samplePairSize = size;
        int okay = setupCPC(events, size);
        setupOkay = (okay == 0);
        return setupOkay;
    }

    public static void sampleBefore() {
        if (!setupOkay) return;
        recordBefore(sampleIndex);
    }

    public static void sampleAfter() {
        if (!setupOkay) return;
        recordAfter(sampleIndex);
        sampleIndex ++;
        if (sampleIndex >= samplePairSize) sampleIndex = samplePairSize-1;
    }

    public static long[][] getSamples() {
        long[][] samples = new long[sampleIndex+1][3];
        for (int i=0; i<=sampleIndex; i++) {
            samples[i][0] = getNanos(i);
            samples[i][1] = getSample(i, 0);
            samples[i][2] = getSample(i, 1);
        }
        sampleIndex = 0;
        return samples;
    }

    private static native void initCPC();
    private static native int setupCPC(String events, int size);
    private static native void recordBefore(int index);
    private static native void recordAfter(int index);
    private static native long getSample(int index, int event);
    private static native long getNanos(int index);
}


compiling:
1  
2  
3  
/usr/j2sdk1.4.2_01/bin/javah -jni CPC
gcc -O -fPIC -c javacpc.c -I/usr/j2sdk1.4.2_01/include/ -I/usr/j2sdk1.4.2_01/include/solaris/
ld -l c -l cpc -B direct -z defs -G javacpc.o -o libjavacpc.so


Example time.java
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  
public class time {
    public static void main(String[] args) {
        int size = 15;
        boolean ok = CPC.setup("pic0=Cycle_cnt,pic1=Instr_cnt", size);
        if (!ok) return;

        int asize = 2000;
        int a[] = new int[asize], b[] = new int[asize];
        if (args.length == 0) {
            for (int i=0; i<size; i++) {
                CPC.sampleBefore();
                for (int j=0; j<a.length; j++) {
                    a[j] = add(a[j], b[j]);
                }
                CPC.sampleAfter();
            }
        } else {
            for (int i=0; i<size; i++) {
                CPC.sampleBefore();
                for (int j=0; j<a.length; j++) {
                    a[j] = a[j] + b[j];
                }
                CPC.sampleAfter();
            }
        }

        long[][] samps = CPC.getSamples();
        for (int i=0; i<samps.length; i++) {
            System.out.println(i+"\t"+samps[i][1]+"\t"+samps[i][2]+"\t"+samps[i][0]);
        }
    }
    private static int add(int a, int b) { return a+b; }
}



hmm, the Java code just doesn't want to seem to want to indent properly. Oh well.
3  Game Development / Performance Tuning / Re: CPU counters via JNI on: 2004-12-31 10:54:56
Quote

That's a shame. I would need something similar for a future project of mine.

I'm going to make a programming game (Robot Battle, Robocode etc.), and I would need a way to monitor and control the CPU time that each thread uses. Would you know some way to do it?


Not in a cross-platform way (which is what you're after). Most OSs simply don't provide this kind of detail. Maybe the RT-Java JVMs would help you here, but they'd have rather specific requirements - eg Sun's one requires Solaris (for its RT/fair-share scheduling).

If you want your robots to be able to run general-purpose Java bytecodes, I think you're going to be stuck. You'll have to restrict their environment somewhat. If you can resitrict the environment in the right way, then you could let normal thread scheduling handle the problem.
4  Game Development / Performance Tuning / CPU counters via JNI on: 2004-12-30 13:13:14
Sun's OS, Solaris has some nice features built-in. One of my favourites is the ability to get CPU performance counter iinformation with built-in commands and libraries, which are also available to normal users.

Java doesn't have a built-in way to access these, so I wrote a little C program which does, and a little Java class to access them via JNI.

Here's some background references:

Performance Analysis and Monitoring Using Hardware Counters:
http://developers.sun.com/solaris/articles/hardware_counters.html

Optimizing Applications with Large Working Sets:
http://developers.sun.com/solaris/articles/optimizing_apps.html

One thing I like about using these counters is that the values are very precise and very stable. I'm only using the number of CPU cycles and instructions executed, but there's many more counters available (for analysing floating-point or cache/memory usage), depending on what the CPU provides.

Here's the output from analysing a simple program (adding  two integer arrays), where samples were taken every iteration of a higher-level loop. The lower level loop does 2,000 iterations each time. These results are with Java 1.4.1 server on a 500MHz UltraSPARC IIe on Solaris 8. Support for a good variety of x86 CPU counters isn't available until Solaris 10 though.

Loop Cycles  Instrs   wall-clock (ns)
0         708823  491297    1344732
1         656932  476504    1204708
2         646695  476503    1185966
3         698243  513165    1286524
4         686206  500540    2025927
5         693815  500516    1272467
6         665485  500529    1220026
7         479821  222572   27391653
8          58270   48423          120922
9          32648   48419           69021
10         32360   48419           68480
11         32268   48419           68119
12         32270   48419           68300
13         32438   48419           68660
14         32272   48419           68119


You can see here that when the compiler kicks in at loop #7 it doesn't affect the cycles and instructions counts that much - this is because the compiler is on a seperate thread, and the counting is only being done for the user thread.

Anyway, this is in very early stages, but it works. First time I've done something with JNI or the CPU performance counter C-library.

If anyone is particularly interested I can post the code, but you'd need Solaris to run it. Last I heard, Linux doesn't have an equivalent built-in, and I'm pretty sure Windows doesn't. MacOS X comes with a program called "monster", but it's not installed as standard.

I'm doing this as part of an article analysing run-time optimisation aspects of JVMs (particularly Sun's JVM).
5  Game Development / Performance Tuning / Re: JRockit optimizations on: 2004-12-14 09:19:16
Quote
Here are some benchmarks:

http://www.shudo.net/jit/perf/
http://www.excelsior-usa.com/jetbench.html

JRockit looks good. But that's no surprise, it's developed in Sweden Grin A new version of JRockit with 1.5 support will be released very soon.



Looking through some of those benchmarks, one thing that I noticed is that Sun's JVMs seem to do better on Opteron (compared to the competition) than on Xeon. I've noticed this myself - last year I was doing some C vs Java stuff on Opterons and Xeons, with Sun's JVM, and on Opteron it was beating the C code all the time - even when compiled with Intel's C compiler! (on Linux)
6  Game Development / Performance Tuning / Re: New VM performance improvements on: 2004-11-16 14: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).
7  Game Development / Performance Tuning / Re: New VM performance improvements on: 2004-10-28 12:32:57
Quote
Tiered compilation is an extension of what HotSpot already does.  So lets step back and talk about how HotSpot and most JIT compilers work in general.  There are two phases in HotSpot, Interpreted and Compiled.  When you start up a Java program, HotSpot first interprets the code until a certain threshold is reached (1000 for Client, 10,000 for Server)


Isn't it 1,500 for client? Or is the -XX:CompileThreshold default for client on this page out of date:
http://java.sun.com/docs/hotspot/VMOptions.html


Quote
then the method is compiled and the compiled version is used (faster than interpreted, usually ALOT faster).  Tiered compilation basically adds a second layer, so that you have interpreted -> fast jit, but low quality code -> slow jit but awesome code.  Tiered compilation gives you the best of both worlds in that you get fast startup and good long running performance.  Hope this helps...


I'll understand if it is too early to say, but - would this be server VM only...? Or would client and server effectively merge with the new model...?
8  Discussions / General Discussions / Re: NEW FORUMS! - Which one to use?I on: 2004-10-07 10:34:28
Quote
All,

Thanks for the feedback so far.  To address a few concerns:
  • I would like to use a Java based forum package if it is functional, looks good, and is relatively easy to administer.
  • The best packages I have found so far are YaBB's new version called Simple Machine, phpBB and vBulletin.  Best meaning feature sets and "polish"  Unfortunately, the Java forums I have found seem to be lacking a bit when compared to these.
  • If I am going to go throught the pain of migrating all of this data and getting a system set up for this community (yet again!) I want to make sure that it is set up so we don't have to go through this excercise again Smiley  That is why I am really trying to get a handle on what you want.
  • I will be reviewing jForum and Jive (again) and really would like to have a Java application here, but my primary concern is giving you what you want and need.


Keep the comments and suggestions coming!

-Chris



I dug around for some other open source Java based forums. The more promising ones I found are:

http://www.mvnforum.com/mvnforumweb/index.jsp

http://www.jzforum.org/

http://yazd.yasna.com/

I haven't tested any of them though. At work, I've been doing similar things for some CMS software - talk about tedious...

The ironic thing is that I helped a friend work on a Java based forum:
http://www.aceshardware.com/forum/

I did most of the optimisations Tongue However, it's pretty light on options...
9  Discussions / General Discussions / Re: Vote for faster Java math functions on: 2004-09-17 12:12:24
Quote

If there was no language change required, it could be done much earlier. The performance advantage could be obtained without changing the language, albeit with less convenience.



Yeah, it's a general trade off - can do case by case work-arounds and hacks to fix the most pressing cases, or use language (or API) features to give a general purpose solution. Work arounds can be done much faster, but are less useful.
10  Discussions / General Discussions / Re: Vote for faster Java math functions on: 2004-09-17 12:08:03
Quote
There's no real pressing need to vote for intrinsics and such though, as Sun are already working on it and committed to it. It'll happen in its own time and voting won't make it any quicker...

Cas Smiley



As far as I know, the actual development work is 100% done. Despite that we might have to wait a long time to actually get it.

It's not going to be in 1.5.0 FCS and might not appear at all in a production release until we get to 1.6.0. If it gets more votes it'll get a higher priority, and so we should then see it released earlier (eg a 1.5.0_0x bug-fix release).

Though I don't personally have a pressing need for this, I thought it was pretty dumb that we'd have to wait so long to be able to use a speed boost that was already done.
11  Discussions / General Discussions / Re: Vote for faster Java math functions on: 2004-09-17 09:02:50
Quote
...except that Structs are more useful!

Cas Smiley



On the other hand, the intrinsics stuff requires no recoding or anything, and is already done (just not available). If structs do happen, it'll probably be JDK 7 at the earliest...


PS I wrote a proposal for a language idea to some guys at Sun that'd probably give you the same benefits as structs, but would have a number of other benefits (in HPC and multimedia in particular). Unfortunately, its almost certainly harder to add than structs. The main problem probably being fitting it into the Java bytecode specification.
12  Discussions / General Discussions / Vote for faster Java math functions on: 2004-09-16 13:48:43
A little rallying cry - vote on this RFE so it can be given a higher priority:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5005861

It currently has 15 votes. Another 100 and it can be in the top 25.

The work for this has actually been done - see some posts by Azeem Jiva in the Performance Tuning board. Unfortunately, since it's not as high priority as a bug fix, it may be some time before it's actually available (worst case, the 1.6 JVM in 18 months or so). So if we vote this issue up, it should get integrated sooner.

Adding comments would probably help too.
13  Game Development / Performance Tuning / Re: Yet another speed comparison,weird server resu on: 2004-06-23 11:01:33
I have a Mandelbrot program hanging around, which I've tested a bit too.

The inner loop is pretty much identical (actually I changed it to be identical to yours) except I'm using floats here.

On my Athlon XP, 1.4.2_04 server is twice as fast as 1.4.2_04 client. 1.5.0-b2 client is slightly slower than 1.4.2 client.

14  Discussions / Miscellaneous Topics / In-depth article on Sun's Niagara chip on: 2004-04-20 13:55:23
http://www.aceshardware.com/read.jsp?id=65000292

10,000 word article by me on Sun's upcoming 8-core 32-thread UltraSPARC processor for servers.

15  Discussions / Miscellaneous Topics / Re: Sun and MS are friends again on: 2004-04-07 20:53:25
Quote
Nice sumamtion. Thanks Chris.

(Btw what are you up to these days? PM me I'd love an update.)


Probably of most interest to you, I've almost finished the 2nd article in my series on TLP optimised CPU design (or what Sun call thoughput computing). Part 1 is here:
http://www.aceshardware.com/read.jsp?id=60000312

The 2nd article is about Niagara  Smiley

16  Discussions / Miscellaneous Topics / Re: Sun and MS are friends again on: 2004-04-06 20:08:02
Couple of random comments...

First, Rich Green. He was mentioned briefly here - maybe some of you saw the Register article? Well, it very much looks like they got it wrong - he'd already decided to leave to join a start-up anyway:
http://business.newsforge.com/business/04/04/05/2138237.shtml?tid=111&tid=85

Here's a good quick analysis of the higher level issues:
http://slashdot.org/comments.pl?sid=102682&cid=8750685

Another angle: The EU *punished* MS for $600m for being naughty in the EU. Microsoft *settled* for $700m for anti-trust crimes against Sun globally. Suck on that Eurocrats!

btw, the recent EU stuff didn't actually do anything much to help Sun. Obviously there'll be an appeals process anyway. For the stuff that relates to Sun it was more like "let other companies license the protocols" which is pretty much what the US guys said. It also seems Sun will have to pay little money in return. If you look at what Sun sued MS over in the first place, they got nearly everything they asked for - there was never much scope for Sun to be able to do serious "damage" to Microsoft, and anything serious would have taken 5-10 years.

And Scott very much clearly stated his intension to compete against Microsoft. With the license agreement, now makes it easier to replace Microsoft software with Sun software, and you bet he intends to do that (and ditto for Jonathan Schwartz). Sun and MS are certainly not teaming up in any way shape or form - this is more a result of that the current situation was overly negative for both companies. For example, Scott said he decided to initiate discussions about a year ago after customers *asked* him to.
17  Game Development / Performance Tuning / Re: -XX:-OptoScheduling -XX:-Inline on: 2004-03-11 11:45:58
Apart from some references in bug reports, I could't find anything on these either...

On a little Mandelbrot app I have, -XX:-OptoScheduling sped up 1.4.1 by about 10% and 1.4.2_03 had no difference (possibly a bit slower). -XX:-Inline doesn't seem to exist in 1.4.2._03 though -XX:+Inline works (but doesn't help performance)
18  Game Development / Performance Tuning / Re: Best system for drawing ints to screen? on: 2004-02-04 15:12:58
Another tool to help with optimisation is Jfluid:
http://research.sun.com/projects/jfluid/

The most recent version has stuff to track object liveliness and can be used to find memory leaks. I used it for just such a thing last week!


If you'd like to see this become a standard feature of Java 1.5 then  vote for this RFE:
http://developer.java.sun.com/developer/bugParade/bugs/4879835.html
19  Game Development / Performance Tuning / Re: Find out how many CPUs a system has on: 2004-02-04 15:10:13
One thing I have noticed with Hyperthreading is that comparing on a multiprocessor system, the time taken to compile byte-codes is much faster (like 10x faster). Of course, you can just put on -Xbatch and then HotSpot's compiler runs in the foreground, which is more efficient. Basically, if the main thread is on 1 CPU and HotSpot is on the 2nd, then the communication overhead between the threads slows the optimisation down a bit. With Hyperthreading, the optimiser runs on the same CPU as the main thread, so is more efficient.

How much effect Hyperthreading has is highly dependant on your benchmark - with some server benchmarks, a 50% boost is possible, but this is rare.

btw, the latest Pentium 4 (Prescott) has a much longer pipeline making it even less suitable for server work, or more complex code in general. If you want a good development or runtime platform for Java, I'd suggest getting an Opteron or Athlon 64.


If you want more of an introduction to multi-core chip designs (like what Sun is working on), then read my recent article Azn
http://www.aceshardware.com/read.jsp?id=60000312
20  Game Development / Performance Tuning / Re: GC Implementation Specifics on: 2004-01-23 11:37:02
I think MaxInlineSize is the cutoff for total number of bytecodes to inline (ie includes sub-functions too)

The FreqInlineSize explanation doesn't make much sense, but I guess it means that HS will never inline a function which is bigger than this value (in bytecodes).
21  Game Development / Performance Tuning / Re: Semi-OT: Sun's big bad HPC plans for Java on: 2004-01-22 10:57:40
Thanks for the reference Bombadil.

A brief search with Google turned up the following:
http://primates.ximian.com/~miguel/archive/2004/Jan-18.html

Miguel's web log.

Rather sounds he's curious to see if it'll turn up anything useful, and not much more.

22  Game Development / Performance Tuning / Re: Sun's new language... on: 2004-01-22 08:30:21
Quote

From other newstickers: Miguel de Icaza, initiator of the .NET-Linuxproject Mono, is interested in this project, too.


Do you have any references for this? I wonder what made Miguel interested, since from what I read before, he didn't seem terribly interested in Java...

Quote
According to his information Guy Steele at Sun is involved in that new Sun project. (Steele is senior developer and has been involved in the Java Specification). And so on.

Will this be a "low level" Java? Or how does it fit next to Java (or Java fit to this new thing) ?


I've no idea. But here's some guesses: support for byte-codes containing profiling information to make run-time optimisation easier, better targeted and faster. ie an implementation based on this research:
http://research.sun.com/techrep/2002/abstract-118.html

I've no idea how Sun will support interval arithmetic (something they're very keen on for HPC), and maybe this would require byte-code changes, unless it can be done efficiently via objects (perhaps with more efficient objects).

Probably include a way to support advanced hinting to the VM about you're preferences for floating-point accuracy vs speed.

This would all take a certain amount of research work etc. Maybe the best thing to do would have a "HPC" or games variant of Java for some bleeding edge features, which get fed back into "normal" Java once they become stable...?


Quote
Will it run on PS3? ;-)


An idea I had the other day: maybe some of this stuff came out of R&D Sun was doing with Sony over development for the PS3? If PS3 does require heavy use of threads to get maximum performance because it has many CPUs (as seems likely), then it'd be nice having a more thread friendly language for it. In addition, doing the work in Java would help cut down development costs, something the gaming industry would be keen on. However, I wouldn't expect Sony to have a full VM and dynamic optimisation and wouldn't be "pure" Java. Maybe the better thing to do is include profiling and optimisation information in the compiled byte-codes, and the byte-codes are converted to machine code as they're read of the of disk. Not the only changes that'd have to be done.  As an embedded system, PS3 specific libraries could be done for graphics so you don't need to have the large separation between the VM and the OS you have on desktop systems.

Of course, that'd have to be in addition to a more normal environment - PS3 will be able to run PS2 games, and I doubt developers would want to immediately switch to a Java based solution no matter what. Maybe the Java one would be initially aimed at smaller, more cost conscious developers, and could broaden out as it becomes more proven, more optimised etc.

Sounds like a good idea to me, but if I'm right, it'd only be by accident...
23  Game Development / Performance Tuning / XX flags on: 2004-01-21 14:54:29
http://java.sun.com/docs/hotspot/VMOptions.html

Has some detail on a lot of non-standard flags.

The -XX:CompileThreshold, -XX:MaxInlineSize and -XX:FreqInlineSize are interesting since they're about the only flags that affect code optimisation, apart from -client and -server. Almost everything else is GC related (compare and contrast to C compilers!) However, in my experiance they almost never make much of a difference when -server is on, though one of my benchmarks in one particular setting did get a 30% boost if I remember correctly... This isn't a criticism of HS - I think it's really cool that I don't have to bother with this stuff. Let's hear it for automatic optimisation!


Also see the docs on GC tuning with various VMs:
http://java.sun.com/docs/hotspot/index.html
24  Game Development / Performance Tuning / Re: Some performance related Java language ideas on: 2004-01-15 17:00:07
Quote
floats might also be used for size.   Also.. just like in physics class you may choose the representation that has the accuracy required. If you don't know what you are getting with float then how can you make that decision?


If you were using floats for size, wouldn't that often be because of performance reasons...?

Anyway, on second though, changing the spec for float would be bad - too many potential problems for old code. D'oh.

I did wonder if using meta-data (or similar) might be a good way, but from what I understand of floating-point accuracy models, this would be very hard to actually implement in general and on x86 in particular. *sigh*


Quote
The primitive thing is useless IMO.  Call clone() and let the VM optimize.


For many of the optimisations I think my primitve class idea would allow (eg efficient array of objects), it would be really hard for the VM to be able to optimise to a similar degree. It would also require the programmer to really really know exactly what the capabilities of the optimiser are - one false step and bang goes your performance, and trying to figure out why would be really hard.

25  Game Development / Performance Tuning / Re: Some performance related Java language ideas on: 2004-01-15 14:18:01
Quote

Changing the symantics of the language, depending on the type of class is a BIG no no.


I see my suggestion as an addition. I would certainly never recommend preventing older byte-codes from running or older code from compiling. For example, I wouldn't use this to change the current primitive system.


Quote
Also, your assumption that float is normally used for speed, double for accuracy is flawed.

It is far more logical to default to accuracy, and, if the programmer finds accurate calcs. to be the bottleneck, should then have the option of requesting speed over accuracy.


Isn't using double instead of float a "request" for more accuracy in the first place though...? So conversely, isn't using a float a request for speed?


Quote
Your final suggestion, adding operator overloading and new classes for explicitly dealing with SIMD operations is IMO another bad idea :-/
SIMD optimisations are platform/processor specific, the api is meant to be abstract.
SIMD optimisation should therefor be done by the VM jit/Hotspot compiler.


Isn't that what I suggested? The JVM would optimise the code if possible, otherwise it would execute the byte-codes as normal. I thought the example made it fairly clear. You have a class that is an abstract for a pixel and you have methods you can call for typical operations on pixels. Your JVM can optimise the underlying code as any other class, or with special knowledge (since they are standard classes) it can use SIMD instructions instead. The operator overloading (not something I'm a fan of) is just a syntatic sugar.

The example I gave is also very common and standard SIMD operation as far as I'm aware - every modern CPU has them I think. Only some embedded chips don't. For some other types of operation, I agree there may not be enough support or implementation variances might be too much - in which case, either don't support classes that depend on them or warn developers that optimisation support is lacking.
26  Game Development / Performance Tuning / Semi-OT: Sun's big bad HPC plans for Java on: 2004-01-15 09:03:30
Partly funded by a $50m donation from DARPA, Sun is working on some very interesting technology for HPC customers, for products to be delivered in the 2010 timeframe - anyone want a peta-flop computer? An interesting thing is that Sun plan to help improve HPC productivity by using a "Java-like" language (Java, 2010 edition?) with portable HPC code and automatic optimisation. While not terribly useful for Java gaming, I thought some people here would find this interesting:

http://www.ncsc.org/casc/meetings/CASC2.pdf

The above is a presentation from the project lead on the 2010 HPC project (known as Project Hero). Mostly about hardware, but some comments on software and (gasp!) benchmarking. I really like this paper.

For a bit more info on the software side see:
http://www.eetimes.com/sys/news/OEG20031119S0013

http://www.internetwk.com/breakingNews/showArticle.jhtml?articleID=17000493


They talk about using a "Java-like" language. I'd expect it to be mostly built on top of Java (would be mostly pointless and a waste of money to not use Java), though some features (enhancements to Java byte-codes for example) might appear on a special HPC version first, then get migrated into standard Java when it's mature.
27  Game Development / Performance Tuning / Some performance related Java language ideas on: 2004-01-15 08:38:14
I had some Java language ideas recently, and decided to write them up and post to JavaLobby, but as of yet I've had no replies. I decided to post it here too:
http://www.javalobby.org/thread.jspa?forumID=152&threadID=10670

I don't claim to be an expert in this stuff, but here's some interesting ideas I had. Comments welcome.

By default, "float" should be optimised for performance while "double" should be optimised for accuracy. In other words, since float is typically used for speed, it should be optimised as such by default and since double is most often used when accuracy is crucial, it should be optimised for accuracy by default. Currently, both are optimised for accuracy by default. (I'm sure the HPC guys want more flexible optimisation options for doubles too, but here's a quick and simple idea I think most people could agree on)

"primative" class modifier: an instance from a "primative" class does not use references, it uses unique pointers. With the code "int c = 1; int d = c;" the variable c is copied to d, in "Object c = new Object(); Object d = c;" variable d becomes a reference to c. With the new primative class, "PrimativeObject c = new PrimativeObject(); PrimativeObject d = c;" copies c to d - creates new object. A decent JVM optimiser would be able to "inline" most uses so that the JVM doesn't actually need to do object creation/deletion for them. One major use of this class is to have data structures with minimal memory useage (which may require other features of normal objects to be removed from primative objects too). In other words, an array of 1000 primative classes which just had one non-static variable (an "int") would take up almost exactly as much memory as int[1000] while being much more useful. This would be good for 3D, multi-media and some maths stuff - eg arrays of complex numbers. Could have a special sub-type of "primative class" for numbers which can use numerical operator overloading - eg could do "ComplexNumber c = new ComplexNumber(1, 1); ComplexNumber d = c * c;" (I'm NOT suggesting operator overloading should be allowed in general)

Number formats with SIMD optimisation support: use standard primative classes with operator overloading to define some new standard classes. This would be to help performance and ease of implementation for user code for multimedia apps, particularly 2D graphics processing for some of the more unusual data types. For example, say you have a 2D image (with 24-bit rgb pixels) and want to brighten the image a bit - you can just add 1 to all the rgb values, but if a value is already at 255 (max of 8 bit unsigned) then adding 1 will make it wrap around to 0, which you don't want (what will happen in Java will depend on what you use for the calcuations - signed ints or signed bytes). Many modern CPUs have SIMD instructions where you can do the add with the checking to prevent wrap-around in just one cycle, for all 3 values (or 4 if you include alpha-channel). If you have standard data types in Java spec for the various types of multi-media number formats, then the JVM can map operations on these to SIMD instructions in CPUs. So if you have "ARGB c = new ARGB(255,255,255,255); ARGB brighten = new ARGB(0,1,1,1); c+= brighten;" then not only is that much simpler than what you'd have to do today, it could be optimised increadibly well, and in a portable way too.
28  Game Development / Performance Tuning / Re: JADE: Another HashMap and more on: 2003-11-14 12:08:18
Generally, what you want is a efficient int HashMap, or some other collection. As others have pointed out, auto-boxing won't mean primatives suddenly can be used efficiently with general purpose collections.

What you want is the generics stuff, and a JRE/VM that will optimise for this. Ie you use a HashMap that is compile time constrained to only use int's for the keys and/or values. At runtime the JRE or VM can then substitute in an int optimised HashMap instead of the default one.

However, I don't think primatives can be specified for generics - ie would have to be Integer object not int. Since an Integer object isn't modifiable, could argue that functionally, storing them as ints wouldn't make any difference. I think that'd be the case unless you were doing something that specifically depended on object references...
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

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

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

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

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

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

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

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

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (32 views)
2014-08-08 02:01:56

Norakomi (42 views)
2014-08-06 19:49:38
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!