WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Miscellaneous

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WinBatch on Multiple Core CPU

 Keywords:  Multiple Single Process Dual Core CPU Thread Threaded

Question:

I have some winbatch program burning a lot CPU. On a single CPU machine, they use 100 % of the CPU, on a Core2 DUO, they use 50% of each CPU. My question is : is Winbatch multi-threated, does it realy take advantage of multi CPU ?

Answer:

High utilization is often caused by loops that don't include a TimeDelay. For example, if you are running a polling loop that checks a registry value or file on disk continuously without a delay, CPU will spike. Simply adding an appropriate TimeDelay will make a huge difference. Put in as much delay as is acceptable for your process. Even a tenth of a second really helps (TimeDelay(0.1)) but the longer the better (in terms of giving up CPU to other processes).

WinBatch is mostly a single threaded application - it usually does not spawn more than one thread of execution to perform tasks. However, this does not mean that WinBatch does take advantage of multi-core processing in several ways.

For example, the newer multi-core CPUs are very sophisticated animals. The latest Xeon processor 5500 series CPUs can actual take certain tasks within a single threaded process and split the work between multiple threads, when it can determine that it would be an advantage to do so. Very cool stuff.

And single threaded applications almost always gets a performance boost on Multi-core systems because they do not have as much competition from other applications and the OS itself.

Also keep in mind that multiple threads does not necessarily means improved performance. Multi-threading a task can actually make it run slower. It requires careful analysis to determine when multi-threading a given task is the right thing to do.

If you really think you have a WinBatch script that will benefit from multiple threads you can always divide the work up between two WinBatch processes. Of course, this means you are responsible for spitting the work up and putting it back together again if necessary.


Article ID:   W17983
Filename:   WinBatch on Mutliple Core CPU.txt
File Created: 2009:04:23:09:53:22
Last Updated: 2009:04:23:09:53:22