• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

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 .
0
zizi21
Asked:
zizi21
  • 6
  • 6
1 Solution
 
Hugh McCurdyCommented:
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.
0
 
zizi21Author Commented:
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 ?
0
 
Hugh McCurdyCommented:
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
zizi21Author Commented:
Thanks for replying. It is appreciated.
0
 
Hugh McCurdyCommented:
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.
0
 
zizi21Author Commented:
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.
0
 
Hugh McCurdyCommented:
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.
0
 
zizi21Author Commented:
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..
0
 
Hugh McCurdyCommented:
Thanks.  Found some docs for you

http://www.mjmwired.net/kernel/Documentation/iostats.txt

It might be what you want.  Of course, it's all the reads/writes for all programs unless you isolate the program to its own partition.
0
 
zizi21Author Commented:
Thank you very much. I would look at it now.
0
 
zizi21Author Commented:
Thanks a lot.
0
 
Hugh McCurdyCommented:
Glad it helped.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now