From: Stratos Karafotis <stratosk@semaphore.gr>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
cpufreq@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 linux-next] cpufreq: ondemand: Calculate gradient of CPU load to early increase frequency
Date: Thu, 04 Apr 2013 02:30:32 +0300 [thread overview]
Message-ID: <515CBB98.4020607@semaphore.gr> (raw)
In-Reply-To: <3060957.HxB12olH3c@vostro.rjw.lan>
[-- Attachment #1: Type: text/plain, Size: 2163 bytes --]
On 04/03/2013 02:14 PM, Rafael J. Wysocki wrote:
> On Wednesday, April 03, 2013 12:13:56 PM Viresh Kumar wrote:
>> On 3 April 2013 12:01, stratosk <stratosk@semaphore.gr> wrote:
>>> I'm sorry, I don't understand.
>>> The goal of this patch is not energy saving.
>>
>> He probably misunderstood it...
>>
>>> The goal is to detect CPU load as soon as possible to increase frequency.
>>>
>>> Could you please clarify this?
>>
>> But he is looking for some numbers to prove your patch. Some numbers
>> that shows performance is better with your changes...
>
> Yes. If the goal of the patch is to improve performance, it would be good to
> know that it does meet the goal. IOW, *something* is supposed to be better with
> the patch and if so, numbers in support of this should be provided.
>
> Thanks,
> Rafael
I tried to do some measurements simulating a CPU load with a loop that simply counts
an integer. The first test simulates a CPU load that lasts 2 x sampling_rate = ~ 20000us.
The second ~40000us and the third ~60000us.
There are 5 runs in each test. In each run the benchmark program counts 20 times with
early_demand off and 20 times with early_demand on and takes the average times.
I run the benchmark program on 3.9-rc5 + early_demand patch. My CPU is the i7-3770 @ 3.40 GHz
Please find below the results, and the benchmark code attached.
Please note, that the idea of this patch is to push the CPU to max frequency few sampling
periods (1 in most cases) earlier for a more responsive system.
Thanks for your time,
Stratos
--------
counter 10,000,000
run early_demand off early_demand on diff
1 20183us 20100us 0.41%
2 20127us 20091us 0.18%
3 20121us 20034us 0.43%
4 20262us 20043us 1.08%
5 20192us 20101us 0.45%
counter 20,000,000
run early_demand off early_demand on diff
1 40037us 39846us 0.47%
2 40051us 39829us 0.55%
3 39996us 39845us 0.38%
4 40104us 39876us 0.57%
5 40090us 39841us 0.62%
counter 30,000,000
run early_demand off early_demand on diff
1 60010us 59834us 0.29%
2 59560us 59854us -0.491%
3 60006us 59827us 0.29%
4 59998us 59828us 0.28%
5 60012us 59866us 0.24%
[-- Attachment #2: bench.c --]
[-- Type: text/x-csrc, Size: 1943 bytes --]
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
struct timeval start, end;
unsigned long long i, cnt;
long utime, seconds, useconds;
void enable_early() {
system("echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/early_demand");
}
void disable_early() {
system("echo 0 > /sys/devices/system/cpu/cpufreq/ondemand/early_demand");
}
void calibrate()
{
sleep(1);
gettimeofday(&start, NULL);
for (i = 0; i < 1000000000; i++);
gettimeofday(&end, NULL);
seconds = end.tv_sec - start.tv_sec;
useconds = end.tv_usec - start.tv_usec;
utime = seconds * 1000000 + useconds;
printf("Calibrating\n");
printf("Elapsed time: %ld microseconds\n", utime);
/* find the counter for 10ms */
cnt = i * 10000 / utime;
printf("cnt: %ld\n", cnt);
}
long do_bench()
{
gettimeofday(&start, NULL);
for (i = 0; i < cnt; i++);
gettimeofday(&end, NULL);
seconds = end.tv_sec - start.tv_sec;
useconds = end.tv_usec - start.tv_usec;
utime = seconds * 1000000 + useconds;
printf("Elapsed time: %ld microseconds\n", utime);
return utime;
}
void benchmark()
{
const int iter = 20;
long total_off = 0;
long total_on = 0;
int diff_perc;
unsigned int i;
/* calibrate(); */
cnt = 10000000;
disable_early();
do_bench(); /* do a first benchmark but do not count in total */
sleep(5);
for (i = 0; i < iter; i++) {
total_off += do_bench();
usleep(500000);
}
total_off /= iter;
printf("early_demand off - average time: %ld microseconds\n", total_off);
enable_early();
do_bench(); /* do a first benchmark but do not count in total */
sleep(5);
for (i = 0; i < iter; i++) {
total_on += do_bench();
usleep(500000);
}
total_on /= iter;
diff_perc = total_off - total_on;
printf("early_demand on - average time: %ld microseconds\n", total_on);
printf("diff: %d\n", diff_perc);
}
main ()
{
printf("Starting benchmark\n");
benchmark();
}
next prev parent reply other threads:[~2013-04-03 23:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-03 6:31 [PATCH v3 linux-next] cpufreq: ondemand: Calculate gradient of CPU load to early increase frequency stratosk
2013-04-03 6:43 ` Viresh Kumar
2013-04-03 11:14 ` Rafael J. Wysocki
2013-04-03 23:30 ` Stratos Karafotis [this message]
2013-04-04 4:54 ` Viresh Kumar
2013-04-05 19:50 ` Stratos Karafotis
2013-04-09 16:56 ` Stratos Karafotis
2013-04-10 3:22 ` Viresh Kumar
2013-04-16 18:34 ` Stratos Karafotis
2013-04-26 14:41 ` Stratos Karafotis
-- strict thread matches above, loose matches on Subject: below --
2013-04-04 7:21 stratosk
2013-04-04 6:47 stratosk
2013-04-04 6:51 ` Viresh Kumar
2013-02-20 20:50 [PATCH " Stratos Karafotis
2013-02-21 4:59 ` Viresh Kumar
2013-02-21 11:31 ` [PATCH v2 " Stratos Karafotis
2013-02-21 15:33 ` Viresh Kumar
2013-02-21 17:39 ` [PATCH v3 " Stratos Karafotis
2013-02-22 1:56 ` Viresh Kumar
2013-02-22 5:57 ` Viresh Kumar
2013-02-22 12:47 ` Rafael J. Wysocki
2013-03-29 22:27 ` Stratos Karafotis
2013-03-29 22:38 ` Rafael J. Wysocki
2013-04-02 13:50 ` Rafael J. Wysocki
2013-04-02 15:49 ` Stratos Karafotis
2013-04-02 22:55 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=515CBB98.4020607@semaphore.gr \
--to=stratosk@semaphore.gr \
--cc=cpufreq@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).