fine granularity nanosleep not power efficient in c++ program on linux -
i trying call sampling function periodically within c++ thread on linux machine. restart function after short period, ideally 1 msec, i'm finding power (in watts) consumed 1 msec period prohibitively high: system runs @ double power level when period 5 msec. keeping power low major concern functionality want.
specifically,
void* loop_and_sample(void* arg) { while(1) { sample(); nanosleep((struct timespec[]){{0,1000000}}, null); } }
takes 2x power of:
void* loop_and_sample(void* arg) { while(1) { sample(); nanosleep((struct timespec[]){{0,5000000}}, null); } }
i have determined difference in power usage of sampler @ 2 frequencies negligible, , power consumption comes sleep call. is, if comment out sample() line in both snippets above, second still takes half power. ideas how might able reduce power consumed sleep call?
fyi, i'm running ubuntu 3.2.0 on 24-core intel xeon , search of /boot/config frequency shows following:
cat /boot/config-3.2.0-48-generic | egrep 'hz' config_rcu_fast_no_hz=y config_no_hz=y # config_hz_100 not set config_hz_250=y # config_hz_300 not set # config_hz_1000 not set config_hz=250 config_machz_wdt=m
however, running script: http://www.advenage.com/topics/linux-timer-interrupt-frequency.php, found kernel timer interrupt @ least 4016 hz (which 4x frequency sample at). help!
the problem not sleep call @ all, fact cpu can't power , down fast. cpu won't instantaneously use less power after go sleep needs time so. when go sleep longer period of time cpu able reduce power usage better.
i'm not sure there's can here, although potentially underclocking cpu might power usage when waking more frequently.
Comments
Post a Comment