Java application developped under Linux running ridiculously slow under Windows

H

hshdude

Hi,

I have been working with a time-criticial application written in Java by my
predecessors in the lab. It's a server that keeps track of objects running
around in real time, with clients connecting via TCP/IP to get information
about those objects. The clients can then display that information in
various (mostly graphical) ways and send requests to the server for a
particular object to change its behavior (e.g. speed). Clients and server
initially ran in separate processes, but now run as separate threads within
the same process (in a largely unsuccessful attempt to speed things up).

The application has so far only been used under Linux but now the need arose
for it to be runnable under Windows. Running it isn't really the problem,
the problem is the speed with which it runs. There aren't any hard
computations involved and it runs much slower on Windows than on Linux even
when run on the same (physical) machine, to the extent that it's unusable as
it need to run in real time. Does anyone have any idea what might be going
on here?

Thanks in advance

cheers,
Arnold


[I'm posting this on three groups at the same time that seem relevant.]
 
M

Michael Borgwardt

hshdude said:
The application has so far only been used under Linux but now the need arose
for it to be runnable under Windows. Running it isn't really the problem,
the problem is the speed with which it runs. There aren't any hard
computations involved and it runs much slower on Windows than on Linux even
when run on the same (physical) machine, to the extent that it's unusable as
it need to run in real time. Does anyone have any idea what might be going
on here?

There are programs called profilers that tell you exactly where an application
spends its time. Get one of these and use it.

Guesswork is a very bad basis for performance tuning.
 
A

Ann

hshdude said:
Hi,

I have been working with a time-criticial application written in Java by my
predecessors in the lab. It's a server that keeps track of objects running
around in real time, with clients connecting via TCP/IP to get information
about those objects. The clients can then display that information in
various (mostly graphical) ways and send requests to the server for a
particular object to change its behavior (e.g. speed). Clients and server
initially ran in separate processes, but now run as separate threads within
the same process (in a largely unsuccessful attempt to speed things up).

The application has so far only been used under Linux but now the need arose
for it to be runnable under Windows. Running it isn't really the problem,
the problem is the speed with which it runs. There aren't any hard
computations involved and it runs much slower on Windows than on Linux even
when run on the same (physical) machine, to the extent that it's unusable as
it need to run in real time. Does anyone have any idea what might be going
on here?

Thanks in advance

cheers,
Arnold


[I'm posting this on three groups at the same time that seem relevant.]

Does it use threads? The implementation of threads is different I believe.
 
H

hshdude

Ann said:
hshdude said:
Hi,

I have been working with a time-criticial application written in Java by my
predecessors in the lab. It's a server that keeps track of objects running
around in real time, with clients connecting via TCP/IP to get information
about those objects. The clients can then display that information in
various (mostly graphical) ways and send requests to the server for a
particular object to change its behavior (e.g. speed). Clients and server
initially ran in separate processes, but now run as separate threads within
the same process (in a largely unsuccessful attempt to speed things up).

The application has so far only been used under Linux but now the need arose
for it to be runnable under Windows. Running it isn't really the problem,
the problem is the speed with which it runs. There aren't any hard
computations involved and it runs much slower on Windows than on Linux even
when run on the same (physical) machine, to the extent that it's
unusable
as
it need to run in real time. Does anyone have any idea what might be going
on here?

Thanks in advance

cheers,
Arnold


[I'm posting this on three groups at the same time that seem relevant.]

Does it use threads? The implementation of threads is different I believe.

Yes, it does use threads. Originally I had a separate process run for each
client. Due to the slow performance I changed it so that there is one
single process with several threads for the server and all the clients.
That didn't seem to speed things up much though.
 
H

hshdude

Michael Borgwardt said:
There are programs called profilers that tell you exactly where an application
spends its time. Get one of these and use it.

Guesswork is a very bad basis for performance tuning.

Thanks, I'll look into that!
 
J

John B. Matthews

Michael Borgwardt said:
There are programs called profilers that tell you exactly where an application
spends its time. Get one of these and use it.

Guesswork is a very bad basis for performance tuning.

Indeed. You should also examine your Windows system when the Java
program _isn't_ running. Check specifically for visues, adware and
similar resource draining malware.
 
C

Chas Douglass

Ann said:
hshdude said:
Hi,

I have been working with a time-criticial application written in
Java by my
predecessors in the lab. It's a server that keeps track of objects running
around in real time, with clients connecting via TCP/IP to get information
about those objects. The clients can then display that information
in various (mostly graphical) ways and send requests to the server
for a particular object to change its behavior (e.g. speed).
Clients and server
initially ran in separate processes, but now run as separate
threads within
the same process (in a largely unsuccessful attempt to speed things
up).

The application has so far only been used under Linux but now the
need arose
for it to be runnable under Windows. Running it isn't really the problem,
the problem is the speed with which it runs. There aren't any hard
computations involved and it runs much slower on Windows than on
Linux even
when run on the same (physical) machine, to the extent that it's
unusable
as
it need to run in real time. Does anyone have any idea what might
be going
on here?

Thanks in advance

cheers,
Arnold


[I'm posting this on three groups at the same time that seem
relevant.]

Does it use threads? The implementation of threads is different I
believe.

Yes, it does use threads. Originally I had a separate process run for
each client. Due to the slow performance I changed it so that there
is one single process with several threads for the server and all the
clients. That didn't seem to speed things up much though.

Which is a prime example of "premature optimization".

Such a refactor could be expected to improve performance IF the problem
POSSIBLY might have had to do with insufficient memory (SOME
implementations of threads will use less memory than separate processes)
or MAYBE communication (SOME implementations of thread/thread
communcations are faster than SOME implementations of process/process),
or process start time versus thread start time, or whatever.

Take this is a lesson that shooting in the dark rarely hits the target.
Get some illumination on the problem before trying again to solve it.

Sorry to rag on you -- I've been beat up so many times to optimize before
we know where the problem is, so I get a little heated.

Chas Douglass
 
M

Matthias Ernst

hshdude said:
Thanks, I'll look into that!

While in the end the output may be very nice, I always find profilers
a little difficult to set up. I mostly use poor man's sampling: hit
CTRL-break (Windows) / CTRL-Backslash (UNIX) repeatedly to get some
thread dumps (with many threads, these will be long). Often it's easy
to tell where the bottleneck is. If you still have no idea after a
minute, then go get a profiler ...

Matthias
 
E

Ed Elud

You might also want to take a good look at your application startup
memory settings (heap size) - if you're not using any, then, it is
possible that a default is being applied - which maybe causing garbage
collection issues, etc. Also, by default, Windoze generally splits
memory allocation around 40/60 to 60/40 in RAM and the other in
Virtual Memory - often without much regard to total available memory.
Thats often why you can increase memory on an Windoze system and not
notice exponential application speed.

Mind you, these are generalizations which I have found to be mostly
true.

Hope this helps.


Chas Douglass said:
Ann said:
Hi,

I have been working with a time-criticial application written in
Java by my
predecessors in the lab. It's a server that keeps track of objects running
around in real time, with clients connecting via TCP/IP to get information
about those objects. The clients can then display that information
in various (mostly graphical) ways and send requests to the server
for a particular object to change its behavior (e.g. speed).
Clients and server
initially ran in separate processes, but now run as separate
threads within
the same process (in a largely unsuccessful attempt to speed things
up).

The application has so far only been used under Linux but now the
need arose
for it to be runnable under Windows. Running it isn't really the problem,
the problem is the speed with which it runs. There aren't any hard
computations involved and it runs much slower on Windows than on
Linux even
when run on the same (physical) machine, to the extent that it's
unusable
as
it need to run in real time. Does anyone have any idea what might
be going
on here?

Thanks in advance

cheers,
Arnold


[I'm posting this on three groups at the same time that seem
relevant.]


Does it use threads? The implementation of threads is different I
believe.

Yes, it does use threads. Originally I had a separate process run for
each client. Due to the slow performance I changed it so that there
is one single process with several threads for the server and all the
clients. That didn't seem to speed things up much though.

Which is a prime example of "premature optimization".

Such a refactor could be expected to improve performance IF the problem
POSSIBLY might have had to do with insufficient memory (SOME
implementations of threads will use less memory than separate processes)
or MAYBE communication (SOME implementations of thread/thread
communcations are faster than SOME implementations of process/process),
or process start time versus thread start time, or whatever.

Take this is a lesson that shooting in the dark rarely hits the target.
Get some illumination on the problem before trying again to solve it.

Sorry to rag on you -- I've been beat up so many times to optimize before
we know where the problem is, so I get a little heated.

Chas Douglass
 
T

Tim Jowers

While in the end the output may be very nice, I always find profilers
a little difficult to set up. I mostly use poor man's sampling: hit
CTRL-break (Windows) / CTRL-Backslash (UNIX) repeatedly to get some
thread dumps (with many threads, these will be long). Often it's easy
to tell where the bottleneck is. If you still have no idea after a
minute, then go get a profiler ...

Matthias

bongo, please let us know what you find out. The Java app I use at
work on Windows runs unacceptably slow. Pretty sure it is Windows as
the CPU sits pegged (dual 2.8GHz Dell). Windows seems to have become
slower and slower over the last several years.
 
H

hshdude

Tim Jowers said:
(e-mail address removed) (Matthias Ernst) wrote in message

bongo, please let us know what you find out. The Java app I use at
work on Windows runs unacceptably slow. Pretty sure it is Windows as
the CPU sits pegged (dual 2.8GHz Dell). Windows seems to have become
slower and slower over the last several years.

Thanks for everyone's input! I'll let you know when I do find out what the
problem is, though it might take a while. It's "only" for my side job and I
have busy times at school ahead. So far I too have the impression that
either Windows or the JVM is just ridiculously slow as our application is
really neither memory- nor computationally intensive.
 
H

hshdude

I owe this thread a message about the outcome.

After printing out GC messages and giving the process more heap space than
it could possibly need, and not seeing any change in speed, I traced down
the bottleneck by hand (still hoping I could avoid having to get a
profiler).
As it turns out, for each simulated object (the application I'm talking
about is a generic simulation of of whatever things you want simulated), a
message-passing routine was called once per update cycle, sending a message
to an optional software agent. When not running the agent simultaneously,
an exception is thrown and ignored. So to make a long story short, throwing
that exception (or realizing that the recipient agent is not alive) takes
neglicable time under Linux, but an entire second under Windows... I simply
threw out the message-passing code as we don't need the agent for our
Windows version of the application.

Sorry the solution wasn't more general so that other people could have
profited from it as well.

Thanks to everyone for their input!!
Arnold
 
D

Dimitri Maziuk

hshdude sez:
I owe this thread a message about the outcome.
[ exceptions ]

This is a known problem with exceptions.
Feed, say, 10,000 valid floats to the following:
try { float f = Float.parseFloat( str ); }
catch( NumberFormatException e ) {}
and time it. Then feed 10,000 invalid floats through and time
that (FVO "invalid float" including numbers in scientific format).
Then compare the times and weep.

IOW "exception" is called that because it's thrown in exceptional
circumstances. If it's a recoverable error that you expect to see
during normal program execution, you want to have a subroutine
return an error value that you can check in a plain if() instead.

Dima
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top