Click to See Complete Forum and Search --> : Java seems a little sluggish on Intel
Niminator
11-30-2001, 08:42 AM
OK, I have a 933 mHz celeron, snd my friend has a dual-processor 500 mHz Mac G4, OS X. I wrote a program using threads, and it runs like a turtle on my machine, and like lightning on his. I'm talking at least 10 times as fast. Any idea why? Is Apple hardware really that much better? The program had a total of about 4 threads running (at least by me) at one time. It was a gui, so I'm sure the jvm had a couple threads as well, listening on the buttons and such. Also, if this helps, I started the window the program ran in as setSize(800x600), and by simply making that window smaller, I could see dramatic increases in speed.
bwkaz
11-30-2001, 10:09 AM
Which version of the JVM?
Older versions had MAJOR speed problems, and this was most of the reason Java got its initial "slow language" reputation, but recent JVM's (at least 1.3 should be good, some older ones were all right too) are a LOT better. Make sure you're using the same version of the JVM on both machines.
Other than that, just the simple fact that his G4 had 2 processors might explain it. Even though his processors did have two or three threads each, yours had five or six. All that context switching takes some time (but in my experience, it isn't too noticeable -- especially on the newer Intel chips; the 386 took FOREVER to task switch).
I've seen NT4 on a dual-processor Pentium II-266, and it kicked the pants off NT4 on a single-processor PIII-600. Granted, that's NT4, but still.
If neither of those is it, then I'm not really sure.
Oh, wait. You said making the window smaller helped improve speeds? What video card is in each computer? If your Intel machine has a crappy 2MB 2D card, that would explain it.
[ 30 November 2001: Message edited by: bwkaz ]
[ 30 November 2001: Message edited by: bwkaz ]
lazy_cod3R
11-30-2001, 11:10 AM
Its not the intel machine , its because of the duel cpu.
When you are running threaded code on a single cpu machine the execution of the threaded code is actually still serialized, its time shared and swapped between each thread because you cant have actual concurrecny, there is only one cpu in the machine so only one thread in actual fact can execute at any one time.
On the otherhand your friends computer has 2 cpu's so he can actually process 2 threads simultaneously one on each cpu(given that the os supports this)making it run faster then a single cpu. If you had a deul as well your code would run just as fast as his more or less.
[ 30 November 2001: Message edited by: lazy_cod3R ]
Niminator
12-01-2001, 04:10 AM
so a single cpu at nearly 1000 mHz runs about 10 times slower (I'm serious, it is amazingly slower) than 2 cpu's running at around 500 mHz. See, I figured it had something to do with the differences in architectures in Motorola vs. Intel. By the way, we were both running the same version of jdk, 1.3.1, so that wasn't the difference.
I have got to get a dual-processor setup if it makes that huge of a difference.
lazy_cod3R
12-01-2001, 08:15 AM
Dont be that hasty unless of course you where planning on getting a duel before :).
It can do with alot of things, firstly you have to make sure that the os you are running the code on has support for duel cpu's.
Secondly it matters as to what each thread does, if the work of each thread is small then each thread may be able to complete within each timeshare of the cpu(single). so for every time its on the cpu the actual thread is completed so baisclly the thread is only on the cpu once, this can effect how long things seem to run for.
Third you have to make sure that there arnt more processes on one machine then the other when your testing because this will effect the time amount of work that gets done on the cpu (obviously the more processes one system has the longer your program will have to wait to get served) try to make sure that they are both running no extra processes.
fourth remeber that multiple cpus dont make things run faster, they just allow more work to be done, so for example if you have one process with no threads it will run at the same speed on a duel or a single cpu because its only one task, the single cpu will have this process on its one and only cpu and the duel will have this task on one of its cpu's whilst the other stays idle doing nothing, you can see that by adding another task to the duel it can *in theory* do 2 things at once making to seem like things are running twice as faster when really its just more work done not speed.
Dont expect that by getting a duel it will dramaticlly increase the speed of things, there is overhead with duel cpu's which may not increase the work linearly so 2 cpu's doesn't always mean twice the amount of work.
But obviously having 2cpu's is cool :)