LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 02-05-2010, 03:03 PM   #1
melkoraton
LQ Newbie
 
Registered: Jan 2010
Posts: 10

Rep: Reputation: 0
CPU instructions per process


Hi
Is there a way to show or count how many CPU instructions a particular process is using or uses?
In my work we develop a web application and I'm responsible of maintaining the web server.
The app lets you handle data online so each client that uses the web application has a folder associated to it, where his data is stored. (/var/www/html/test) for example.
The idea is to get how many CPU instructions the httpd process for that particular folder is having. Is there a way to do this?
Thanks in advance, and sorry for the complicated explanation
 
Old 02-05-2010, 03:04 PM   #2
Web31337
Member
 
Registered: Sep 2009
Location: Russia
Distribution: Gentoo, LFS
Posts: 399
Blog Entries: 71

Rep: Reputation: 65
define CPU instructions?
 
Old 02-05-2010, 03:30 PM   #3
melkoraton
LQ Newbie
 
Registered: Jan 2010
Posts: 10

Original Poster
Rep: Reputation: 0
Like x86 for example, instructions from the instruction set of the CPU.
Examples:
goto
add
substract
etc

Like assembler... very low lvl
 
Old 02-05-2010, 03:44 PM   #4
Web31337
Member
 
Registered: Sep 2009
Location: Russia
Distribution: Gentoo, LFS
Posts: 399
Blog Entries: 71

Rep: Reputation: 65
who knows. some tens of thousands per second? why does that bother you? if performance is critical in your environment, consider using other webserver than apache httpd: that is too slow.
say, nginx.
p.s. there are no 'goto' and 'substract' in x86 assembly. jmp and sub perhaps are the one you meant.

Last edited by Web31337; 02-05-2010 at 03:47 PM.
 
Old 02-07-2010, 12:04 AM   #5
noden
LQ Newbie
 
Registered: Aug 2009
Location: Denmark
Distribution: Debian
Posts: 29

Rep: Reputation: 18
Quote:
Originally Posted by melkoraton View Post
Like x86 for example, instructions from the instruction set of the CPU.
Examples:
goto
add
substract
etc

Like assembler... very low lvl
I dont think that would be allowed by the kernel without running it in a debugger.
But it would be an insanely high amount. The CPU also do more than one instruction at one time depending on the amount of ALUs in the CPU.
Some instructions take several cycles to perform though.
Getting that kind of data would load the CPU more than running apache itself.
I would reccomend just keeping track of the normal average CPU usage for that process.
 
Old 02-07-2010, 02:48 PM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,919

Rep: Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779
Quote:
Originally Posted by melkoraton View Post
Like assembler... very low lvl
I'm sorry, but it is more difficult than that; there are instructions that are pre-fetched but never used, there are instructions that are brought into cache, but never used (actually, it is way more complicated than that, because of the cache levels) there are instructions that are decoded but never executed, there are instructions that are provisionally executed but are withdrawn, and there are instructions that are executed...of course, the executions that are executed take very different amount of time depending on whether they were already in cache, which cache they were in and the actual instructions themselves.

Of course, the time taken will be vastly more influenced by whether the app is swapped in or out than by plus or minus a few instructions, and the time to do anything with the data will also be way more influenced by how the data write interacts with the i/o scheduler (where are you with elevator seeks?), but that may or may not be a problem to you, because you could consider that time to be transparent if its all queued up and happening in the background.

Now, what did you want to know, particularly given that I have oversimplified everything in order to answer in a finite time?
 
Old 02-07-2010, 10:56 PM   #7
melkoraton
LQ Newbie
 
Registered: Jan 2010
Posts: 10

Original Poster
Rep: Reputation: 0
well I was expecting answers like this. A weird client wanted that specific data... I simply thought it was impossible to get that info because its way to low lvl and way too difficult to get..
Like I said there is no way around they asked for that data particulary...
Anyways thanks a lot for the replies
 
Old 02-08-2010, 07:13 AM   #8
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,919

Rep: Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779
Quote:
Originally Posted by melkoraton View Post
A weird client wanted that specific data...
I'm guessing that this client is a human, or collection of humans, rather than one half of a client/server computer program collection.

Quote:
I simply thought it was impossible to get that info because its way to low lvl and way too difficult to get..
Like I said there is no way around they asked for that data particulary...
No, but you may be able to measure how much time a sequence of instructions takes, and if you can define a worthwhile sequence of instructions (or, alternatively, measure the percentage of time that a thread takes) that may get you the information that the client really wants, rather than what has been asked for.
 
Old 02-09-2010, 05:31 PM   #9
aspire1
Member
 
Registered: Dec 2008
Distribution: Ubuntu
Posts: 61

Rep: Reputation: 22
Are you sure they don't mean how much cpu time on average ( or something like that ) is each process using? Otherwise, give them an assembly language printout of your code, an instruction set manual for the cpu, a calculator and wish them a fond farewell
 
Old 02-10-2010, 05:53 AM   #10
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,919

Rep: Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779
Quote:
Originally Posted by aspire1 View Post
Are you sure they don't mean how much cpu time on average...
That may well satisfy their real requirement, but it is entirely up to the OP whether he tells that this is an alternative possibility or whether he (she?) just leaves it at something like 'What you have asked for isn't really possible or useful.'

Quote:
Otherwise, give them an assembly language printout of your code, an instruction set manual for the cpu, a calculator and wish them a fond farewell
There is effectively no danger that they get anything useful from that process....however, there is a danger that they, in order to achieve a result, do it wrong (usually, processes like this, which are a PITA and both political and useless are given to the most disposable of assets to perform, and that doesn't help in getting a useful answer, but an answer may come out all the same) and as a result of doing it wrong come to some conclusion about what changes you have to make to your code, and that might be problematic.

I mean, if they were to decide on the basis of false cycle counting that, in order to cope with the increase in traffic that they have predicted (and you can argue whether this is more imaginary than the cycle counting, or not) that you have to re-write your code in a different language, would you think that this was a good outcome?

The other conclusion that they might come to is 'we don't need to upgrade hardware until we get to xxxxx hits per hour' and this can also be problematic if they do need a hardware upgrade at some lower hit level and they are sitting on 'proof' that they do not need to do it.
 
Old 02-10-2010, 07:52 PM   #11
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Definitely need to ask the client what they are trying to achieve/measure, but at the higher level. Counting cpu instructions is unrealistic.
 
  


Reply

Tags
cpu, instructions, server, web


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
CPU time for process? m1n Linux - Newbie 3 03-06-2009 07:52 AM
How to get %CPU usage of a process romydmisc Linux - Newbie 2 05-24-2006 02:02 PM
per process cpu utilization kunal_patel22 Linux - Software 1 05-19-2005 11:26 AM
Process scheduling (CPU) kiwi_bloke *BSD 1 08-29-2004 10:07 PM
CPU usage of a process asharma Solaris / OpenSolaris 7 03-29-2003 03:17 PM


All times are GMT -5. The time now is 11:35 PM.

Main Menu
Advertisement
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