zizi21
asked on
count physical input / output operations
hi,
i am programming in C to run the program on linux. I am trying to find the number of physical input / output operations made to disk to get the data ?
Is there any function in linux or C or a profiler that helps to do this..thanks .
i am programming in C to run the program on linux. I am trying to find the number of physical input / output operations made to disk to get the data ?
Is there any function in linux or C or a profiler that helps to do this..thanks .
I doubt that information is available to even the Linux kernel. The kernel might be able to count the requests it made. But due to caching by disk drives, the kernel doesn't know (nor does it care) which operations actually involve a physical read or physical write and how many there were per each request.
ASKER
But, would there a function to count disk cache misses. This is because if there is a disk cache miss, you need to go to disk and get it ?
Caveat: I could be wrong and you should wait for other opinions.
Disk cache misses are handled invisibly by the disk drive's firmware. Drives used to be accessed by Cylinder/Head/Sector. During that time, I think such metrics were possible. But that was long ago.
I would wait around to see if someone else comes by with a solution. Just because I think the theory won't allow it doesn't mean I'm right.
Disk cache misses are handled invisibly by the disk drive's firmware. Drives used to be accessed by Cylinder/Head/Sector. During that time, I think such metrics were possible. But that was long ago.
I would wait around to see if someone else comes by with a solution. Just because I think the theory won't allow it doesn't mean I'm right.
ASKER
Thanks for replying. It is appreciated.
No problem.
It might help to know why you want to count disk activity.
Otherwise, I'd let this rest for a while and give others a chance to show up. It's Friday night in the U.S. and people might be doing other things. (Other than watching baseball and working on the computer at the same time.) Good luck in your quest.
It might help to know why you want to count disk activity.
Otherwise, I'd let this rest for a while and give others a chance to show up. It's Friday night in the U.S. and people might be doing other things. (Other than watching baseball and working on the computer at the same time.) Good luck in your quest.
ASKER
Hi !
I am testing the efficiency of the my programs. I am unable to rely much on the timings because there is are chances that the disk caches might cache the data. Another way is to find the number of seeks made to the hard disk. So, if the program makes too many seeks, you can say it is in inefficient.
Thanks again for your time.
I am testing the efficiency of the my programs. I am unable to rely much on the timings because there is are chances that the disk caches might cache the data. Another way is to find the number of seeks made to the hard disk. So, if the program makes too many seeks, you can say it is in inefficient.
Thanks again for your time.
In that case, you could put logging in the program. Of course, that will slow the program but perhaps not much. Depends on how many read/write instructions you have.
How are you doing the disk I/O? read/write/seek? fread/fwrite/fseek? Something else?
You could count them. Perhaps wrapper functions like my_read, my_write, etc. They could count the times used. In this case, I think using global variables are OK.
Just an idea.
How are you doing the disk I/O? read/write/seek? fread/fwrite/fseek? Something else?
You could count them. Perhaps wrapper functions like my_read, my_write, etc. They could count the times used. In this case, I think using global variables are OK.
Just an idea.
ASKER
Thanks again for replying.
Besides using fseek , fread and fwrite, I am using mmap. The main problem that I am facing is that with mmap, the implementation details are being hidden from the programmer. So, I was hoping there might be some tool that will count that .
I just came across this tool called ":/sys/block/sda/sda7/stat and it seems to be giving some info. Not sure how reliable is this info...number of reads, writes..
Besides using fseek , fread and fwrite, I am using mmap. The main problem that I am facing is that with mmap, the implementation details are being hidden from the programmer. So, I was hoping there might be some tool that will count that .
I just came across this tool called ":/sys/block/sda/sda7/stat
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much. I would look at it now.
ASKER
Thanks a lot.
Glad it helped.