Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
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]
  ignore  |  Print  
  GCJ, a quest for speed.  (Read 9228 times)
0 Members and 1 Guest are viewing this topic.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #30 - Posted 2003-10-21 10:55:37 »

Heh, HelloWorld is now 4.6MB.  Shocked

Other than some really trivial things, I couldn't get anything to compile and run correctly. Some test programs required some hacks to get it to compile.
For example for doing a quick and dirty new Date().toString(), I finally had to add 2 static references to gnu.java.locale.Calendar.class and gnu.java.locale.LocaleInformation.class in my source, which is a bit weird  Huh. The little test program BTW is a simple socket that returns the time, but the GCJ version compiles and runs (after inserting the extra lines of dummy code), but behaves differently (I couldn't test the response from the socket using a browser where I can with the java version).

If I can't even get these miserable 50 lines of code running, I won't even bother with compiling a LWJGL program.

Using GCJ is certainly no walk in the field  Embarrassed.

I'm not giving up just yet, but so far no result at all.

Offline SpongeBob

Junior Devvie




Who lives in a pinnapple under the sea


« Reply #31 - Posted 2003-10-21 18:11:51 »

Quote

Heh, HelloWorld is now 4.6MB.  


Thats pretty good figuring a simple HelloWorld in regular java is over 30MB is size.

Now some of you are thinking that I must be crazy BUT you may be forgetting that a GCJ compiled program includes a Java runtime.  So, add the size of your JRE with any java app you write to figure the size in comparison.

There is a DLL you can link your GCJ programs to for Windows that takes out the java runtime fat (Google for libgcj.dll).  Thats nice if you are planning on having multiple GCJ apps on the same system.

Also, check out UPX (upx.sf.net).  Use it to deflate GCJ apps.

upx --best HelloWorld.exe

Quote

Some test programs required some hacks to get it to compile.
For example for doing a quick and dirty new Date().toString(), I finally had to add 2 static references to gnu.java.locale.Calendar.class


Yes, this is a known issue.  But its the only oddity I have ever seen.  What other problems are you having?

Quote

If I can't even get these miserable 50 lines of code running, I won't even bother with compiling a LWJGL program.


Post your code.  I curious to whats going wrong.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #32 - Posted 2003-10-22 05:14:23 »

Here's my test:

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  
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;

/**
 * TServer.java
 */

public class TServer {

        private static final Class class1 = gnu.java.locale.Calendar.class;
        private static final Class class2 = gnu.java.locale.LocaleInformation.class;

        int port;

        public TServer(int port) {
                this.port = port;
        }

        public void run() {
        boolean waiting = true;

        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(port);
        } catch (IOException e) {
            System.err.println("Could not listen on port: " + port);
            System.exit(1);
        }

        while (waiting) {
                Socket clientSocket = null;
                System.out.println("Waiting for request");
                try {
                    clientSocket = serverSocket.accept();
                } catch (IOException e) {
                    System.err.println("Accept failed.");
                }

                PrintWriter out = null;
                        try {
                                out = new PrintWriter(clientSocket.getOutputStream(), true);
                        } catch (IOException e) {
                                System.err.println("Error getting PrintWriter:" + e);
                        }

                out.println(new Date().toString());
                out.close();
                try {
                                clientSocket.close();
                        } catch (IOException e) {
                        }
        }
        try {
                        serverSocket.close();
                } catch (IOException e) {
                }
        }

    public static void main(String[] args) throws IOException {

        if (args.length != 1) {
                System.out.println("Usage: TServer [port]");
                System.exit(1);
        }

        TServer t = new TServer(Integer.parseInt(args[0]));
        t.run();


    }
}

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

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #33 - Posted 2003-10-22 05:38:33 »

Quote
Quote:
Heh, HelloWorld is now 4.6MB.    


Thats pretty good figuring a simple HelloWorld in regular java is over 30MB is size.

Now some of you are thinking that I must be crazy BUT you may be forgetting that a GCJ compiled program includes a Java runtime.  So, add the size of your JRE with any java app you write to figure the size in comparison.


Yes, you're absolutely right but downloading a runtime with every GCJ app makes a one time download of a more functional JRE look more attractive still.

I'm still interested in getting GCJ to compile my LWJGL stuff, but it will be of very limited use: To make a one time download of the game or game demo a bit smaller and easier.
I did some more tests and there seems to be no speed gain with GCJ. For example the 'ArrayTest' code from the http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Tuning;action=display;num=1065650709 thread is a tiny bit slower in GCJ compiled form than running the java code in the 1.4.1 client VM.

Erik

Offline Woz

Senior Newbie




A Troll who lives in a hole


« Reply #34 - Posted 2003-10-22 09:21:01 »

I didn't have that much trouble getting hello world down to < 500K.

You've just got to use lots of GCC switches!

Page 2 of this topic has the correct switches listed to get < 500K.

They are supposed to be doing something about the size in GCJ V3.4 but how much difference it will make is another matter - bearing in mind that you have to provide the functionality of the JVM and the compiled code in order for it to execute properly.

Jacko points out that a preview of 3.4 is available from the http://www.thisiscool.com/gcc_mingw.htm but whether that includes the size modifier I don't know. Neither have I been able to try it yet due to an annoying combination of zero time and a hard drive failure.

As to the array speed test, this does not surprise me but did you try it with the Array Bound Checking switched off in GCJ?

The simple fact is that the array fill is compiling into exactly what it has been asked to be. Which is not particully optimal for execution speed on the cpu and memory subsystem. This is a problem of it looking fast to humans, but not being fast for a cpu. For example I would not use that code in C (other than for easy of use that is [read laziness  Cheesy]).

There has been a lot of success with GCJ and SWT, for example Eclipse has been successfully compile, which is hardly a small product.

Hopefully using GCJ will become easier.

-------
Woz.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #35 - Posted 2003-10-22 10:30:07 »

Quote

I didn't have that much trouble getting hello world down to < 500K.

You've just got to use lots of GCC switches!

Page 2 of this topic has the correct switches listed to get < 500K.


Yes, I'm aware of the GCC switches and upx and all to shrink the executable. I'm not too worried about all that. The reason I mentioned the straight helloworld example is now 4.6MB, was just an observation that the helloworld.exe went from 2.6 to 4.6MB as of GCJ 3.4.

Quote
but did you try it with the Array Bound Checking switched off in GCJ?

*blush* er I'm afraid not until just now:
The GCJ version is not ~13% faster than the client VM version and still 5% faster than the server VM version (wasn't the server VM supposed to eliminate bounds checks too?).
That's very good indeed.  Smiley

Pages: 1 [2]
  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.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (51 views)
2014-12-03 16:27:13

CopyableCougar4 (48 views)
2014-11-29 21:32:03

toopeicgaming1999 (115 views)
2014-11-26 15:22:04

toopeicgaming1999 (103 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!