Dervin Thunk
Dervin Thunk

Reputation: 20119

How to setup a computer for controlled experimentation profiling algorithms?

We work on empirically measuring the running time of certain algorithms (to check against their asymptotic behavior). I'm trying to come up with a set of rules to "clean up" our target computer before an experiment. This is not really performance at the level of Agner Fog, but still I would like to start with as clean a machine as possible (and keep it with a constant overhead as much as I can). I have so far:

Obviously, repeating the experiment several times will give me some statistical power, but I'd still like to do this in as clean a machine as possible.

What other tricks do people know to keep a machine constant during program profiling? This is a Linux machine and it is ok if the "rules" are Linux specific.

Upvotes: 2

Views: 111

Answers (2)

binarym
binarym

Reputation: 367

I don't know if it's part of the "power management" topic you mentionned, but some CPUs implement frequency scaling. Make sure it's configured to run at its max frequency.

root@chupa-ThinkPad-Edge:/sys/devices/system/cpu/cpu0/cpufreq# ls
affected_cpus  cpuinfo_cur_freq  cpuinfo_transition_latency     scaling_available_governors  scaling_governor  scaling_setspeed
bios_limit     cpuinfo_max_freq  related_cpus                   scaling_cur_freq             scaling_max_freq  stats
cpb            cpuinfo_min_freq  scaling_available_frequencies  scaling_driver               scaling_min_freq
root@chupa-ThinkPad-Edge:/sys/devices/system/cpu/cpu0/cpufreq# cat scaling_cur_freq 
800000
root@chupa-ThinkPad-Edge:/sys/devices/system/cpu/cpu0/cpufreq# cat scaling_governor 
ondemand
root@chupa-ThinkPad-Edge:/sys/devices/system/cpu/cpu0/cpufreq# cat scaling_available_governors 
conservative ondemand userspace powersave performance 
root@chupa-ThinkPad-Edge:/sys/devices/system/cpu/cpu0/cpufreq# echo performance > scaling_governor 
root@chupa-ThinkPad-Edge:/sys/devices/system/cpu/cpu0/cpufreq# cat scaling_governor scaling_cur_freq 
performance
1600000
root@chupa-ThinkPad-Edge:/sys/devices/system/cpu/cpu0/cpufreq# cd ../../cpu1/cpufreq
root@chupa-ThinkPad-Edge:/sys/devices/system/cpu/cpu1/cpufreq# cat scaling_governor scaling_cur_freq 
performance
1600000

Upvotes: 1

Kenneth Hoste
Kenneth Hoste

Reputation: 2971

Pull the network cable, so your system is not spending time on network traffic passing by.

Running in single-user mode also helps, because then fewer services are running which could disrupt your measurements.

Keep away from the system while the experiments are running, anything you do (log in, ssh into the machine, 'cat' a file, run an 'ls', etc.) will affect the measurements.

But, do realize there no such thing as a stable measurement, the only way to be sure is to run the experiment a large number of times, and use the proper statistical methods to report performance. This becomes especially important when you are going to compare performance between experiments.

Upvotes: 1

Related Questions