Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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.
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?
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
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.
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.