Click here to Skip to main content
16,022,060 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I run two identical processes. One of them requires 90 minutes to complete. The other takes 150 minutes. I expected them to be the same, and am unsure what the problem is.

What I have tried:

I did the above experiment on a different machine and the running times are more as expected (90 minutes each).
Posted
Updated 26-Sep-24 4:25am
v2
Comments
0x01AA 26-Sep-24 10:56am    
Define 'identical'. I assume you don't mean the one and the same executable?
LF FF 26-Sep-24 11:22am    
It can be two instances of processes of the same executable (doubleclick/start the same .exe twice, for example), or two different executables (doubleclick/start different .exe files from the identical source code). I have tried both with the same results.
0x01AA 26-Sep-24 12:03pm    
Do you run them in the same time? If yes, can you maybe see (in task manager) that one of them consumes the whole CPU in the first 60 minutes?
LF FF 26-Sep-24 12:36pm    
Thank you. Yes, they are run at the same time, and they are started at the same time. I notice one of them is consistently higher in terms of the % CPU usage but not by much (maybe a 1-3% difference at most). Each show about 10% CPU consumption. The one which takes longer may sometimes drop to 9% or so. Hard to characterize as they fluctuate. I am now wondering if there a way to force the CPU consumption to be higher in one or both, to, say, 20% each? There are a bunch of other processes (probably Windows and vendor-specific processes to the laptop, I hesitant to mess with those for now as the total CPU consumption is shown as 20-50%).

As I research this, I see that Processor Affinity and CPU Priority can be manually set in Task Manager, but I am also wondering if the way CPU is consumed by the app can be set in the C#/.NET.
siliconvideo 26-Sep-24 12:08pm    
Need more information, Are the 2 processes running in parallel or sequential? Are they crunching the same data set? Is there a memory limitation (if one process needs more memory, it could be swapping to the hard drive more slowing everything down.) What are the other processes running during your test runs. How do the different machines compare? ...

1 solution

We really can't tell - we have no idea what your app is doing. But ... the most likely thing is resource locks. For example, if the app attempts to write to a file then only one of them can access it at a time - so the other has to wait for the first to close the file and then continue.

So start with your code and either use the Stopwatch class to monitor in real time (to separate log files) where one instance is running slowly compared to the other then narrow down on those sections, or look closely at your resource usage.
 
Share this answer
 
Comments
LF FF 27-Sep-24 8:46am    
I think you nailed it OriginalGriff. I had the apps read duplicate, separate (identical) sets of files and the issue magically disapears (both run at 90 minutes). So I think there was some kind of resource lock when both executables are reading the same set, as you said. Thank you!
OriginalGriff 27-Sep-24 10:25am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900