Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seriously slow? #16

Open
kokizzu opened this issue Mar 19, 2015 · 10 comments
Open

Seriously slow? #16

kokizzu opened this issue Mar 19, 2015 · 10 comments

Comments

@kokizzu
Copy link

kokizzu commented Mar 19, 2015

I tried to execute this code using jvmgo

import java.util.*;
class prime {
        public static void main(String[] args) {
                ArrayList<Integer> res = new ArrayList<Integer>();
                int last = 3;
                res.add(last);
                while(true) {
                        last = last + 2;
                        boolean prime = true;
                        for(int v : res) {
                                if(v*v>last) break;
                                if(last%v == 0) {
                                        prime = false;
                                        break;
                                }
                        }
                        if(prime) {
                                res.add(last);
                                if(res.size()%100000 == 0) System.out.println(last);
                                if(last>9999999) break;
                        }
                }
        }
}

but it took too much time, more than 578.62s (I terminate execution because it took too long), for comparison openjdk 8u40 gives complete output within 1.23s

OS: 64-bit ArchLinux
Kernel version: 3.18.7-1
Processor: i3-4150
RAM: 16GB

@zxh0
Copy link
Owner

zxh0 commented Mar 19, 2015

Hi, thanks for your issue. This project is coded for fun and learning. Besides that, it is in the baby stage(two months old, mostly programmed by one guy). So, do not expect too much : ) I will try my best to finish this project and make it run faster.

zxh0 added a commit that referenced this issue Mar 19, 2015
@kokizzu
Copy link
Author

kokizzu commented Mar 19, 2015

Btw this project is cool 🆒 i'll look forward for the completion 👍

@hami9x
Copy link

hami9x commented Mar 20, 2015

@zxh0 could there be a bug or something related to this? I have a feeling that no matter how slow, it shouldn't take that long. I don't know anything but yeah, my 2 cents.

@zxh0
Copy link
Owner

zxh0 commented Mar 21, 2015

Yes, it's too slow :( I did some cpu profile and code optimization yesterday, but I feel it's not the time to do this kind of stuff. For now, this jvm is still a toy. Thread, ClassLoader, Java Memory Model, File, Socket... a lot of things are still not working(correctly). I will try to implement all of that and then go back to this issue.

@wishstudio
Copy link

While peeking at the code I think it's already using a threaded interpreter, right?
Then to achieve good performance you must implement JITs, which I suspect will take years to be competitive... (look at LuaJIT)
I agree it's better making things working than making them performant for now.

@zxh0
Copy link
Owner

zxh0 commented Apr 2, 2015

Actually, writing a JIT is beyond my ability :(

@andrewchambers
Copy link

Go can't easily support a JIT currently because Go's memory model clashes with most ways of doing jit. Creating a JIT itself is not particularly hard.

@ailabs-software
Copy link

What if we instead transpiled Java to Golang, and then could get native execution speed?

Kind of like GWT transpiles Java bytecode to JavaScript.

@bmarwell
Copy link

@BPILOT why use go then? GCC has gcj which compiles Java to native x64 elf binaries.

@xiangzhai
Copy link

Actually, writing a JIT is beyond my ability :(

How about migrate VMKit to latest LLVM?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants