Skip to main content
GameDev.net gamedev.net
🔒 Locked

random vs fixed sleep interval

Started by flounder Sep 19, 2010 at 11:43 AM 5 replies 2.9k views
Original Post
flounder
flounder
I need to process a bunch of data, and it will take about a week of constant cpu time to process it all. The computer I'm going to be doing this on is somewhat old so I want to avoid taxing it too much, and I want to be able to use it during that time. After some testing I've decided I want to sleep the main processing loop for 10ms every 500 loops. My question is: would it be better for the computer if I don't sleep it at exactly every 500 loops and instead sleep it randomly between 400-600 loops (or some interval like that)? The reasoning for this is that since the computer will be processing the data for such a long time, sleeping it at such a constant interval might wear out certain parts of the cpu more than others. I don't know enough about how a computer works to know if this is absurd or not, so that's why I'm asking.
coder0xff
coder0xff
I'd say there's no need to worry about the interval. The cpu won't wear down due to periodic moments of rest.

However, I think there may be a better solution for you. Rather than sleeping, you can set the processes priority to a lower level so that it will run full crank 100% when you aren't using the computer, but the moment you do something, it gets off loaded so the CPU can focus on other tasks. This is a feature that has been in windows for a long time. Find the process in task manager, right click it, and set the priority to idle.
Two things are infinite: the universe and human stupidity; and Im not sure about the universe. -- Albert Einstein
Antheus
Antheus
Instead of worrying about this, make sure to implement periodic snapshots. The chance of something going wrong is rather high for uninterrupted computation over a time span of a week. Running CPU at 100% for such long time is essentially burn-in test which exposes many subtle instabilities.

So every 10 minutes or so dump entire state which can be used to resume computation from that point. This is by far the most important part for this type of stuff.

Quote:
such a long time, sleeping it at such a constant interval might wear out certain parts of the cpu more than others

Unless the CPU can balance workload across cores, there's nothing you can do.
flounder
flounder
Quote:
Original post by coder0xff
However, I think there may be a better solution for you. Rather than sleeping, you can set the processes priority to a lower level so that it will run full crank 100% when you aren't using the computer, but the moment you do something, it gets off loaded so the CPU can focus on other tasks. This is a feature that has been in windows for a long time. Find the process in task manager, right click it, and set the priority to idle.


I'm trying to keep the cpu from running full throttle even when I'm not using the computer. I've had to get a part of this computer replaced once before because of heating issues, so I'm trying to avoid it altogether.

Quote:
Original post by Antheus
Instead of worrying about this, make sure to implement periodic snapshots. The chance of something going wrong is rather high for uninterrupted computation over a time span of a week. Running CPU at 100% for such long time is essentially burn-in test which exposes many subtle instabilities.

So every 10 minutes or so dump entire state which can be used to resume computation from that point. This is by far the most important part for this type of stuff.

Quote:
such a long time, sleeping it at such a constant interval might wear out certain parts of the cpu more than others

Unless the CPU can balance workload across cores, there's nothing you can do.


It's already set up to dump what I've processed every hour or so since I figured I might need to start/stop sometime in the future.

The processing is being done on one core. I'll just stick with the fixed interval then.
cache_hit
cache_hit
Why don't you just set the priority of the process to the lowest possible value? Then you'll always have free CPU cycles when you want to use the computer for something else. But if nothing else is going on, it will run at full speed.
swiftcoder
swiftcoder
Quote:
Original post by Antheus
Instead of worrying about this, make sure to implement periodic snapshots. The chance of something going wrong is rather high for uninterrupted computation over a time span of a week.
QFE.

We used to do some fairly large bittorrent simulations, and their is nothing like having your process killed-off 5 days into a 6 day run...

Snapshot as often as you can afford to, and make sure *beforehand* that you have a method to identify corrupt snapshots (i.e. a checksum), and that you can resume from any snapshot *even* if you have to make changes to the program.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
jmastro
jmastro
Just out of curiosity, what are you doing that's going to take a week to complete?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.