Menu

.exe slows down intermittently

Richard
2008-03-31
2012-09-26
  • Richard

    Richard - 2008-03-31

    Hi,

    I'm using dev c++ 4 for a project at university on XP home. I'm running a relatively simple statistical program which prints its progress to the screen every 100, 1000 or whatever steps. I'm finding that when i run it the rate at which it progresses seems to oscillate between slow and fast speeds with the faster speed being ~1.5/2 times faster (closer to two). My first thought was windows was being unhelpful, but i checked and throughout the cpu usage for my program was 99%. Because of the nature of the problem the changes in the speed can only be computational in origin and not what i'm modelling. It would be very helpful if i could solve this because its not the difference between 10 and 20 minutes here, but more 10 and 20 hours... So any help would be much appreciated!

    Thanks.

     
    • Anonymous

      Anonymous - 2008-03-31

      Some points to check out:

      Do is there some other process, even in background. I.E. Antivirus. Malware scanning? etc.

      Do you access your data thru a network?

      Do depend your's data of a repository that can shrink or grow?

      Can change the complexity to the data access (delay) over the time?

      Can change the complexity of the computing step over the time?

      Can be some memory leak on the process?

      In my own experience there a nothing like "relatively simple" in this job. Just I've spent a half weekend in a relatively simple routine until I realized that the chars behind of US ASCII return a negative value...

       
    • Richard

      Richard - 2008-03-31

      I'm running it totally on my own computer, i took out the internet card and disabled all non essential processes to see if that was the case, but the cpu usage for my program remains constant while it speeds up and slows down.

      For the rest of your questions i should explain what i'm doing. My program basically finds a average of the time for a random walker to reach a target sweeping over different energy values for an association energy level. Obviously the physics isn't important, but the code is identical for each 'energy run through' with only the value changing and after each run through everything is reset and the (very small) arrays which i take any data from remain unchanged (over the timescale of these oscillations) as they are determined and created beforehand.

      So in summary, complexity of step and size of data repository remain constant. Also these changes in speed happen at any point in the code, so they happen before any change in what the program is doing happens. Also at the point in the program it sped up, on the next iteration it could slow down at that point. so basically it makes no sense why its happening (also bearing in mind it seems to change between two very constant speeds) and i'm finding it hard to think of things in my code it could be.

      I'm not vastly experienced with c/c++ so you may have to bear with me, for example clarify exactly what you mean by memory leakage.

      I'm wondering whether it is a hardware quirk or windows mucking about with the cpu cache or something, but still it doesn't seem hugely obvious.

      Sorry if that doesn't really help matters, but thanks for the suggestions.

       
    • cpns

      cpns - 2008-03-31

      It is probably going to be impossible to give you a definitive answer without seeing (and executing) the code, and without the code this is not really a Dev-C++ or even C/C++ related question.

      Have you checked your programs memory usage? If it needs to resort to virtual memory, the resultant disk swapping will result is drastic changes in speed. Also if you are dynamically allocating memory, this is fundamentally non-deterministic, and memory fragmentation can cause large slow downs.

      To be honest, Occam's razor suggests to me that the problem is probably entirely related to your code - all the other suggestions you or anyone else has made are far less likely it seems to me than just a flawed algorithm.

      Did you mean Dev-C++ 4 BTW? You really should use 4.9.9.2, it uses a newer GCC version and is what is assumed here from a support point of view.

      Clifford

       
    • Anonymous

      Anonymous - 2008-03-31

      > I'm not vastly experienced with c/c++ so you may have to bear with me,
      > for example clarify exactly what you mean by memory leakage.

      I mean persistent memory not freed. I.E. some statement like (but not restricted to)

      int* imptr = new int[nnn];

      without

      delete[] imptr;

      before exiting the scope.

      > I'm wondering whether it is a hardware quirk or windows mucking about with the cpu cache or something, ...

      Although remotely possible (IMHO) perhaps some exotic hardware failure may do your cpu run sometimes at different speed. To exclude the possibility as last resource I suggest run a test in a different system.

       
    • charles elsaesser

      Hello,

      Your system is a multi-processes system and many things are happening during the execution of your executable.
      Even if your process were running alone on the pc, processing would be interrupted at each end of time slice.

      Memory management of such system is not very reliable, but we have to work with it.
      I have a 1GB ram memory and once i tried to request memory in a loop.
      Memory allocation return-code was set to wrong only when i had requested a total amount of 2GB of memory.
      So there are holes in memory management, perhaps due to software errors in underlying libraries, dlls or to asyncronous execution of underlying functions.

      Seeing your problem, i can suggest you to trying 3 actions:

      1) if you do not need C++ programming, i.e. if you do not use C++ special functions or operators, try to compile as a C procedure,

      2) to verify why you meets such instabilities during execution, you could copy your code to a temporary source file and bypass the 'energy run through' sequence , setting the corresponding search time to a constant time, chosen from a possible search time you once previously met.
      So you will be see if the same behaviour occurs again

      3) you do not need, for many applications, to compile using "dev-cpp" . You can compile using msdos command line, both in C programming, or in C++ programming
      By this way a minimal number of "system" libraries will be linked to to load-module, which will avoid useless risks of foreign software errors.
      You only need to put the directory "dev-cpp/bin" into the path and type command
      gcc -o app.exe app.cpp
      If you have special libraries or includes, see the GCC doc.
      Gcc help can be obtained typing
      gcc --help 2>&1 | more

      if you succeed in this problemn rsolution it would be nice you describe briefly what the problem was and how you solved it.

      good luck

       
    • cpns

      cpns - 2008-03-31

      Charles, what are you talking about? You no doubt mean well, but you are way off track I think. Most of your suggestion have no likelihood of achieving any solution and are just a waste of time.

      >> Your system is a multi-processes system and many
      >> things are happening during the execution of your
      >> executable.

      ... except he said that his process had 99% of the CPU so, if true other processes are not having a significant effect. The processor will not be slowing down, so his process must be doing more work.

      >> once i tried to request memory in a loop. Memory
      >> allocation return-code was set to wrong only when
      >> i had requested a total amount of 2GB of memory.

      That's not a reliability issue or a bug or error, that is a 'by-design' architectural limitation. User processes may only have 2Gb total virtual memory in 32bit Windows. See: http://msdn2.microsoft.com/en-us/library/aa366778.aspx

      >> 1) if you do not need C++ programming, i.e. if you do
      >> not use C++ special functions or operators, try to
      >> compile as a C procedure,

      Nonsense! Why would that work!? C++ compilation of C code results in virtually identical code generation as the same C code compiled as C code. In any case C++ is not intrinsically slower than C, so constructs and classes you might use to improve safety or ease memory management may have an overhead, but to create identical functionality in C carries virtually the same overhead, and since such ad-hoc code might be less mature it would probably be both slower and buggier.

      >> 3) [...] You can compile using msdos command line, both in C programming,
      or in C++ programming. By this way a minimal number of "system" libraries will
      be linked to to load-module, which will avoid useless risks of foreign software errors.

      More nonsense. Even if a library is specifically passed to the linker, no library code is linked unless it is explicitly referenced by the application code. And only the object code necessary to resolve those references is linked not the whole library. Moreover, even if redundant code were linked, it can have no effect on execution unless it is explicitly called, and then by definition it needs to be there. Besides the default project options in Dev-C++ do not link any libraries other than the C/C++ standard libraries (implicitly, which happens even from the command line). You only have to take a look at the Compile log to see exactly how the compiler and linker were invoked. Apart from that what "msdos command line"? It's a Windows command line, MinGW is a 32bit application that will not run in MS-DOS, which is a different OS altogether.

       
    • charles elsaesser

      Hello Clifford,

      Do not be so violent .
      I only tried to help a person which was trying to understand what was happening during the execution process of his load-module.

      Did you really read what our friend has writen?

      Did you read what I have writen?

      Take some time to try what I have suggested and shout only if needed.

      No trouble.

      Charles

       
    • Anonymous

      Anonymous - 2008-04-03

      Charles:

      >Do not be so violent

      In my opinion the Clifforsd post is not violent at all. It only says that your mail contain some nonsenses, and comment why that opinion in detail.

      >I only tried to help a person which was trying to understand what
      > was happening during the execution process of his load-module

      Really anyone doubt about your good intention. Usually all people who spend his time in this list try to get help, or offer it.

      Once stated your good intention, I feel that this is the case of the one-eyed guiding to the blind.

      As an expample:

      > 1) ...., try to compile as a C procedure,

      There are nothing like a "C procedure"!!!!

      Of course, I must admit that it is very unpleasant when someone contradicts us in public. In my past I have sometimes. In any event, you have been lucky. Think if you had answered by Soma :-)

      Greetings.

       
    • cpns

      cpns - 2008-04-03

      >> I only tried to help

      You can only help if you know what you are talking about. Given teh many possibilityes, there is no way of determining what is happening, so your 'guesses' are pointless. If he followed your suggestions he would have been doing it for no good reason. How does that help?

      The better approach in such a situation is to consider the possibilities and request further information, tests, or experiments than might aid the investigation. You would also need to justify your request by explaining what it was your were looking for. Only one of you suggestions possibly had that merit.

      >> Did you really read what our friend has written?

      Yes, but parts of your response indicated that you had ignored some of the available evidence. I will admit that the details of his application I did not pay much attention to - it was too vague a description of something obviously quite complex - which is why I suggest that it is the likely source. That is the one part you did make a suggestion that may or may not be helpful, but I would suggest that you were making it on very little information.

      >> Did you read what I have written?

      No of course not! I copy & pasted it with my eyes closed. What do you think!? I have no comment or opinion on the parts of your response upon which I did not elaborate - they may or may not be nonsense, I am not certain that it is the best solution. Instrumenting or profiling the code would seem a better place to start. The OP has set us an impossible task, he is asking us to determine why his code does not work, without sight of the code! Any attempt to make assumptions about that code is futile.

      >> Take some time to try what I have suggested and shout only if needed.

      How could I possibly do that!? It is not my code nor my problem. I am not the originator of this thread. You are very confused.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.