• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in windows

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a Java desktop application running smoothly on LINUX. It only uses a small MB of RAM and a small piece of CPU. But when I try it in WinXP, ON THE SAME COMPUTER, it runs very slowly, EVEN THOUGH THE SYSTEM HAS PLENTY OF RESOURCES AVAILABLE.
The application is actually a game and it is not enjoyable at this slow speed. I've tried to increase heap size, but it is useless (anyway the application needs a very small amount of RAM). CPU usage never goes over 20%, so I'm a bit lost.
Up to now, I can think of these two possibilities:

-The javax.swing.Timer's I use become overloaded, and start to throw events more slowly.

-Some 'julian' in a forum told me about a similar problem he had, which he solved by adding more threads to his program.

Trying to modify the program in either of these two directions would take a lot of time, so I want to listen to some opinions before I start.

Any ideas?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you'd have to tell us more about the application. What do you do with threads, for example? What sorts of graphics things do you do? And what JVM are you using on Windows, and what on Linux?
[ December 08, 2005: Message edited by: Ernest Friedman-Hill ]
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rather than make assumptions and look for rules of thumb which might not apply in your case, look inside to find what the bottleneck is in your case. Find what piece of code, you are spending most of your time in, and what you are waiting for : IO, synchronization, thread start...
 
James Kline
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, Ernest, let me tell you about the program:
It's a game, it's single-threaded and all computations are done in AWTEventQueue. The game reacts to both user-input and events thrown by many javax.swing.Timer. Once the game itself has started, there is no file reading or anything like that which could stop the application.
The game has an interface for the graphic class. Both win and linux work well with a reduced graphic class which only paints essential events. The new graphic class stores in memory small icon-images which it copies to the adequate part of the canvas. I also do some standard java.awt.Graphics painting, like graphics.drawRect(...); And that's all. Before switching to the new painter, I made performance tests on WinXP and linux (always on the same computer) and found that Win was doing sligthly better than Linux at filling the whole Canvas with copies of these small icons chosen with a simple pattern. This is the only essential difference between the old and the new class, so win should be doing fine.
I use the latest version of Sun JVM on both WinXP prof edition and Ubuntu Linux.
This 'Julian ' I mentioned had a similar problem with a single-threaded program , and solved it by converting it to a 4-threaded program. I couldn't do that in a natural way, but I could modify my game to use two threads in a not-too-artificial-way, but chances are I'd be losing my time and maybe get nothing in return.

And for Virag:
Sorry to disent, but when the same bytecode runs so differently on the same computer with Linux and WinXP (not mentioning that WinXP has plenty of resources available), I think there is some general point I need to understand before I start to modify my code. When you use libraries from other people (like javax.swing or java.util) you may find that a problem in your code is only due to some wrong assumption on how those libraries work.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by James Kline:
And for Virag:
Sorry to disent, but when the same bytecode runs so differently on the same computer with Linux and WinXP (not mentioning that WinXP has plenty of resources available), I think there is some general point I need to understand before I start to modify my code. When you use libraries from other people (like javax.swing or java.util) you may find that a problem in your code is only due to some wrong assumption on how those libraries work.



I think what Virag was getting at is that you should use some tools, like a profiler, to find out more details about *what* is slow under windows, without having to guess.
 
James Kline
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure, but what really drives me crazy is that my program does not exhaust the available resources. I do think that there is a general rule involved, something I'd expect to find under headers like:

'Having windows give your Java application all the resources it needs'

or

'Why a perfectly nice program in Linux may LOOK slow under WinXP'

or something like that. Let me explain why:

There can't be a bottleneck in the usual sense, because there is only one thread and there is no waiting, no sleep, no read file, no http-connect. It's only a simple stream of calculations and memory-moving operations. There is available CPU time, so what can be the cause? I can only think of these three:

-WinXP doesn't allocate enough resources. In this case the solution (is there is any) must be simple, like turning a flag on or switching to another JVM.

-The program is slow not because it's overloaded, it looks slow because it's clock doesn't work ok. That is, javax.swing.Timer under winXP will wait much longer than in Linux. In this case I would rewrite my code to use the more reliable java.util.Timer.

-There is some 'black spot', some operation slowing the program. But it doesn't involve CPU time, because there is plenty of it available, neither input-output, as there is none, and neither RAM or BUS speed, I'd say, cause Linux does fine. As the program runs well with the SimplePainter, it may involve the

'filling the whole Canvas with copies of small BufferedImage's chosen with a simple pattern'

that I mentioned, but tests showed Win does better than Linux at that.

I mean, sure I can go and fill the program with traces, but I think I'll find there is no 'worst offender', no method doing much worse than the rest, and I'll be in the same place. The program is pretty uniform, or so it looks when viewed by a programmer with no deep knowledge of hardware. At the point I'm now, and if no one has any ideas or clues, I'd rather go and change the Timers to java.util.Timers than look for a bottleneck. But please tell me if you feel I'm wrong.
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My suggestion is as follows... have you looked at the Windows system itself to be sure that there is not some rogue application consuming CPU cycles? There may be a rogue app sitting on your system consuming 80% of your system resources and hiding it. Have you considered that Windows itself consumes way more resources than Linux?

Did Julian have a game, singly-threaded, with all computations done in AWTEventQueue? If he didn't, then the fact that he split his app into 4 or 14 different threads is not all that relevant to you.

Those are my opinions anyway.. oh, and you have been given some good advice so far. Making statements like " There can't be a bottleneck in the usual sense" means to me that you are not looking at the likely culprits.

That's just my opinion. Your mileage may vary...
[ December 10, 2005: Message edited by: C Clites ]
 
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic