LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-28-2008, 11:25 AM   #1
duryodhan
Senior Member
 
Registered: Oct 2006
Distribution: Slackware 12 Kernel 2.6.24 - probably upgraded by now
Posts: 1,054

Rep: Reputation: 46
Measuring performance on MultiCores


Hi

In general when I want to do performance measurement for different size of inputs , I use the time or /usr/bin/time command or use the gettimeofday etc. inside C.

But for multi core processors is there any way by which I can measure the time taken by the processor in each core ? As well as get the total time taken by the process ?

Note : I do NOT want the total time taken (that I can find using the time command) .. I want the actual time taken in CPU by the program (in multi cores / SMPs the time taken in cpu (sys+user) > (real) as their are multiple cores).


Thanks,

Regards
duryodhan
 
Old 04-29-2008, 05:53 AM   #2
ophirg
Member
 
Registered: Jan 2008
Location: Israel
Distribution: Kubuntu 13.10
Posts: 134

Rep: Reputation: 34
Hi duryodhan

It sounds to me like a task for a profiler, not something to do from the program itself.
try OProfile.

And in anyway, please tell me if you find a better solution...
It's an interesting problem.

Thanks in advance,
ophirg
 
Old 04-29-2008, 08:20 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,284

Rep: Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028
For single-threaded code the likelihood is that all kernel-context code will be synchronous. Hence, extra (processing) engines probably won't be any (or only marginal) benefit. If you *really* (as in *really*) want to check this, Ingo has a patch so that you can see the decisions (all of 'em) made by the scheduler.
Your code may run faster (elapsed time) with extra engines, but the amount of CPU time consumed on its behalf will likely be the same - within measurable statistical anomaly.

However, for multi-threaded code, accumulate separately per thread.

Last edited by syg00; 04-30-2008 at 06:51 AM. Reason: formatting for clarity
 
Old 04-29-2008, 09:01 AM   #4
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,377

Rep: Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108
Having multiple cores or CPUs is an "opportunistic" improvement: it's sometimes done because it has the opportunity to improve the performance of certain workloads, by a certain amount, during certain favorable phases of the moon. But it's not going to be a categorical improvement, nor will it be easy to measure it since the relation of the CPU(s) to the system is holistic: CPU(s) address the entire workload of the entire system at any instant, and their influence can't meaningfully be confined to just-one program.
 
Old 04-29-2008, 09:44 AM   #5
ophirg
Member
 
Registered: Jan 2008
Location: Israel
Distribution: Kubuntu 13.10
Posts: 134

Rep: Reputation: 34
syg00,
Sounds interesting. Where can I find this patch? Does it work with all schedulers?

sundialsvcs,
I don't agree with you. You don't have to have a large number of compute bound processes to block an group of i/o bound processes for a long time. Therefore, if you have 2 cores/2 CPUs, the compute bound processes can run on one core and leave time for i/o bound processes to execute. The amount of time that you save can be quite big.
Also, the CPU does not address the entire workload of the entire system. In fact, on most modern systems, most of the workload is i/o. Most of the time is spent by the CPU waiting for an interrupt.
Another point that I'm not sure of its significance, but I think is worth mentioning anyway, is that when you have a good scheduler that knows how to use multiple cores/processors you get less cache misses. And I know that avoiding cache misses is a very important step in optimizing a compute bound program.
 
Old 04-29-2008, 01:48 PM   #6
duryodhan
Senior Member
 
Registered: Oct 2006
Distribution: Slackware 12 Kernel 2.6.24 - probably upgraded by now
Posts: 1,054

Original Poster
Rep: Reputation: 46
Quote:
Having multiple cores or CPUs is an "opportunistic" improvement: it's sometimes done because it has the opportunity to improve the performance of certain workloads, by a certain amount, during certain favorable phases of the moon.
What?!? For a single process, maybe I agree with you ... that too because many people don't write code that works as multithreaded.

But for normal day to day usage , multi tasking and/or virtualisation tech is helped by obscene amounts by multi-cores/SMPs, afaik.

ophirg : I will try oprofile. lets see. thanks a lot though.
 
Old 04-30-2008, 07:01 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,284

Rep: Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028
I thought I had that patch book-marked, but apparently not. Was when I was investigating the CFS changes, but may have been more general than just that.
Just checked lkml (which I've been ignoring lately), and it looks like a lot of new code in this arena is heading for mainline. Maybe new features available soon.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Measuring Fedora's Boot Performance LXer Syndicated Linux News 0 03-12-2008 04:37 PM
LXer: Measuring Fedora's Boot Performance LXer Syndicated Linux News 0 03-12-2008 03:50 AM
LXer: Measuring Ubuntu's Boot Performance LXer Syndicated Linux News 0 02-14-2008 01:30 PM
Tools for Measuring Multithreaded Performance. Sunilsbjoshi Linux - Server 1 01-26-2007 04:50 AM
Tool for measuring webserver performance coolguy_iiit Linux - General 1 08-23-2006 05:00 AM


All times are GMT -5. The time now is 06:04 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration