










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Information about the cs140 lab08, which focuses on gaining an understanding of disks and their behavior, including the structure of the io path and cache behavior. Students will measure the performance of various disks, including usb memory sticks, local disks, and remote disks, and present their findings during show and tell.
Typology: Slides
1 / 18
This page cannot be seen from the preview
Don't miss anything!
The purpose of this lab is to gain understanding of Disks and their behavior.
There are essentially two parts to this lab:
disks and “disk like” entities. It also includes gaining an understanding of the structure of the IO path and how that path behaves.
and logical fashion – your data should be organized in a way that shows what you find. In order to understand, you may need to do more experiments than the minimum described here. The days of “I don’t understand how I got that answer” are in the past.
The Lab - Overview
Cache Behavior
Caches store data: Disk accesses are painfully time consuming. So caches as seen on the previous page work the same way as processor caches. Caches assume there is temporal and spatial locality of data. Caches hold on to data already read in, on the assumption that data will be needed again. They hold on to modified data assuming that data may be written again; they act as write back caches.
They also pre-read data – you ask for one block, and the system may well bring in the next few blocks. The disk cache is especially clever and reads all the data on the track where the requested data is located; why spin around again if it’s easy to hang on to the data.
Steady State Behavior: Steady state behavior means that there’s a steady, continual, and not too-fast flow of IO requests. If this flow is slower than the slowest component in the IO path (usually the spinning media) then all is happiness.
Pulse Behavior: Occurs when IO requests come faster than the slowest component can handle it. The advantage of this behavior is that you can then watch the actions of that slowest component.
Cache Size: Size matters – bigger is obviously better. When you buy a disk, it comes with a fixed size cache – it will never change. But the OS cache is much more dynamic; the OS allocates memory to disk cache, processes, etc. based on the various demands; so the OS cache is never the same – on most systems you can figure out the size at any instant in time.
Block Consolidation: All IO to the disk is of at least a block in size – that’s 4096 bytes on Windows and LINUX – your program may ask for 17 bytes, but the OS will bring in at least 4096 bytes and cache the remainder. When you do many small writes, the OS hangs on to your requests until an entire block has aggregated.
Similarly, the disk cache tries to take multiple requests, if they’re close together on the disk, and honor them all at the same time – make one request and read/write multiple blocks; what a win!
Cache Behavior
What happens with sequential IO: So your program is happily making disk requests. Sequential IO means that it writes block 0 in the file, then block 1, then block 2, etc. It can make these requests very quickly. But the disk can also satisfy them very quickly because the cache does consolidation and sends to the disk a request to write a large number of blocks – it could well be 100 blocks at a time. Now the program can still request a lot faster than the cache/disk can write, but the program goes very quickly.
What happens with random IO: Random IO means that the program is randomly asking for blocks anywhere in the file – this can defeat the cache’s inherent worth since there’s no locality of reference. It’s a whole different story here. The program can still make rapid fire requests, but the cache can’t do consolidation and so the disk becomes a major bottleneck.
What happens with Writes: A write is “unpended” – by this it means that the system doesn’t require that the data get to the disk before the system call returns to the calling program. As long as the data gets to the OS cache, the system is happy. Now it’s possible to override this behavior, and thus ensure the data gets to the disk on every program request, but we’re not using such behavior (it’s called a “fflush” if you want to modify the program. The reason for this is that the program may not depend on whether the write finished – it can go on with other tasks while the disk does its job.
What happens with Reads : A read system call is suspended until it completes. This is because the program supposedly needs the data that’s being read before it can proceed – so the program halts, waiting for the successful read.
But where does the read get its data – this is just like processor caches. The data may be in the OS cache
Controlling where disk reads get their data will be a major challenge in this project.
Description of ReadWrite.c
To examine the performance of any computer component, you need the appropriate tool. In the same way there are many kinds of screwdrivers, designed for various purposes, this disk performance tool COULD have endless variations – each twist would provide additional information about the IO subsystem; but unfortunately the tool would become more and more complicated. The tool given to you here tries to strike a balance; not too many options, but enough to get interesting results.
The code that provides this functionality is called ReadWrite.c download here .exe
Usage: write
By default, the program will write to the current directory. If you give a complete pathname, it will write to that location.
Notes:
(which are often 1K blocks), megabytes, etc.
random write may not fill the entire file – there may be blocks missing. If you try to read that file, you could very possibly take an error because you’re trying to read what doesn’t exist.
Description of ReadWrite.c
jbreecher@dijkstra:~/public/comp_org/Lab08$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol 25837436 6027008 18476772 25% / /dev/sda2 101105 17563 78321 19% /boot tmpfs 516912 0 516912 0% /dev/shm 140.232.101.133:/home 709068768 87426816 585623360 13% /home
jbreecher@dijkstra:~/public/comp_org/Lab08$ ReadWrite /tmp/big 100000 Write Random Elapsed IO Time = 1.203017 seconds jbreecher@dijkstra:~/public/comp_org/Lab08$ ReadWrite /tmp/big 200000 Write Random Elapsed IO Time = 145.504208 seconds
The “df” command shows the disks mounted on this machine. The first is the local disk on a LINUX
machine. This one says that there’s 25% of the disk used. The 140.232…../home shows the mount of disks
from spears our fileserver.
Cleanup is important. You’re writing large files all over the place. Use /tmp as the location for your local
files. Your remote files will go in your own directory. Please remember to clean up, otherwise we’re doing
backup for your trash files. If you login remotely, do NOT run this code on the gateway machine, younger.
Taking Charge of Your Caches
Spying on Your Caches
The Linux tool available to you that “shows all” is vmstat. A “man vmstat” can teach you all the gory details about how it works and what the various columns mean. In our example below, we will focus on columns “cache”, “bi” and “bo”. For S & T, please be able to explain what’s happening under the CPU section (us, sy, id, wa, st) both in this example and in the vmstat data that you generate. When vmstat is started with an argument, that indicates how often it should print out data – every one second in our case. Note that in the data shown here, the LINUX reported to ReadWrite, and the program reported to us, that the write took 1.49 seconds. But according to vmstat, it took at least 10 seconds to write everything to the disk. Let’s look at this more closely.
jbreecher@dijkstra:~/public/comp_org/Lab08$ ReadWrite /tmp/big 100000 Write Sequential Elapsed IO Time = 1.493796 seconds
Now isn’t this amazing. Here is a run of the ReadWrite program – as the program sees it, the write succeeds in 1.49 seconds. The program is merely responding to the close function succeeding; that says the file is in good hands and the writes are complete. vmstat gives the real picture and says it takes many more seconds to get everything on the disk.. Docsity.com
Spying on Your Caches
Now that you’re an expert on vmstat, your education has just started.
The equivalent OS-spying tool on windows in perfmon. You can practice with this
on your home PC, but of course you will eventually be doing your experiments on
the lab machines.
Starting perfmon -- startrun (open perfmon).
Important buttons – are highlighted on the next slide.
See the add button on the next page – a useful parameter to add is
add( + button ) physical disk Disk Transfers/sec add
there’s a lot here – you will want to play around.
Try “right click in perfmon” properties graph --<vertical & horizontal grid>
Permon produces a graph rather than a list of numbers – this can be easier or
harder to interpret depending on the situation.
Spying on Your Caches
Buttons
Clear Display Add Highlight Freeze
Time measurement – you need to calibrate your grid. This is about 12 seconds.
Here again, ReadWrite is lied to. It thinks the transfer finished in 4 seconds whereas the OS was kept busy for 12 seconds.
What will you Measure and Report?
1. Make vmstat your friend. Be able to explain what is reported there, in detail, for one of your
experiments. I start this analysis on slide 13, but you should be able to explain the mechanisms in more detail.
2. Design an experiment to determine the size of the OS cache. The measurements I did here
should lead you in the right direction. Being able to explain what’s happening in these two runs of ReadWrite will go a long way to helping you develop your own experiment.
jbreecher@dijkstra:~/public/comp_org/Lab08$ ReadWrite /tmp/big 100000 Write Random Elapsed IO Time = 1.203017 seconds jbreecher@dijkstra:~/public/comp_org/Lab08$ ReadWrite /tmp/big 200000 Write Random Elapsed IO Time = 145.504208 seconds
Make sure you have the corroborating vmstat and perfmon data with you for Show
and Tell.
Related questions:
Does Linux or Windows have the best cache performance? How do you best show your data? Does a graph or table do a better job than
the raw data? How do you synthesize your results?
Note that this is a concrete question with an open ended answer. Real
questions are often that way.
What will you Measure and Report?
3. Disk transfer characteristics. What is the fastest rate that data can be written and read on the local
disk? Bring vmstat or other tool output to prove your conclusion. There are many answers to this question that you should provide. (first of all, you need to make sure that you’re actually going to the disk and not being fooled by cached data. Typically this question is answered by measuring
floppy disk? Bring vmstat or other tool output to prove your conclusion. There are many answers to this question that you should provide. (first of all, you need to make sure that you’re actually going to the disk and not being fooled by getting cached data. Typically this question is answered by measuring