Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Increase priority  RSS feed

 
amar nath jha
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am working on an application software that will be executed on windows (I am sure about it).
Now that software has a module which reads an xml file and insert records in database .The size of xml file is really very big so its a time consuming task.To increase the speed of input I set the priority of my windows as high and second time as real time .(Just for trial and it was working fine).

If i use a module in my application that can increase the priority of my application to high /real time just while import module and restore it back to normal state after that module is over.Will it be a good design (I know I am compromising with platform independent feature of my application/java).If its good then which DLL files can I use for this.

Thanks in advance
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this was my problem I would think first in terms of separate Threads for the XML parsing and Database storage tasks.

The database operations are bound to be the limiting factor - I bet the priority the database application has will turn out to be important.

I would experiment with monitoring the CPU utilization by the java app and the database before jumping into fiddling with system priority settings.

Bill
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raising the priority of a process or thread will only make it go faster if it is doing a CPU-intensive task and there is some other process or thread that is also doing a CPU-intensive task. If that is the case, what is the other process or thread that's using the CPU?

Raising the priority will not help if your application is blocked waiting for I/O, network, database etc. But putting tasks onto separate threads could help, by allowing useful work to be done during waits for I/O etc.

Raising the priority of a process or thread above the normal priority can be very dodgy. If your high-priority process or thread begins a long-running CPU-intensive task, then the whole O/S will likely become unresponsive. You may even have trouble killing your process, because you can't get at the Task Manager or command shell.

As an alternative to raising the priority of your process, you could reduce the priority of the other process(es). That's often safer.

Raising the priority of an ordinary Java process to Windows Realtime setting is almost certainly insane. You'll just hang your machine, most likely.

By the way, you generally can't do that sort of thing with Pure Java. Depending on how your machine is configured, you may or may not be able to do it with native code or external programs.
[ December 07, 2007: Message edited by: Peter Chase ]
 
amar nath jha
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your guidence.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To increase the speed of input I set the priority of my windows as high and second time as real time .(Just for trial and it was working fine).

If one area of the app is sluggish, but needs to complete before other logicals in the app - then bumping priority is to be considered. Do not bump the priority way up, just up a notch or two and if that does not address the problem effectively, then the platform is not capable of the work.

Bumping the priority as high as it will go is the standard beginners solution to improving responsiveness. This is not the correct approach, though I suggest continuing the Threads approach as a way of controlling what happens in your program.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
very little in modern computing is CPU bound, so don't look to priorities to solve your 'perceived responsiveness' problems. Use threads, that's why they are there.

nearly all real world applications are IO bound, typically database bound, or user input bound.

Parsing XML files is really not much work, the basic file reading usually takes longer than pulling apart the tags and values.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[PF:]   nearly all real world applications are IO bound, typically database bound, or user input bound.

Dov Bulka has stated that the processor can be the restricting time completion factor, but that would obviously be on a hot OC LAN with earlier processors popular when the book was written. As stated, it is usually the initial read that matters but I think for the original posters design needs that we should point out that if strict a();b();c();d();e();f();g(); sequencing is a design constraint, then only a single thread can and should do the construction and init() of that object. The object can then be passed off to a separate thread for "insert records in database"

At that point if the The size of xml file is really very big the design approach introduces questions descending from the single threaded nature of proprietary windows and the intractability of trying to do scheduling where the underlying platform can render one's scheduling efforts a false promise and coders cold slab of icy chills.
[ December 09, 2007: Message edited by: Nicholas Jordan ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!