Assignment #1: The Art of Computer Science Measurement

Due Date: Tuesday, February 15th, by midnight

Updates

2/13: It is absolutely OK to use read() or other methods to find the number of direct pointers in an inode; write() + fsync() was just one possible approach.

2/13: If you want to clear the file system cache, an easy way to do so is to first unmount the file system and then to remount it (umount/mount). Of course, you have to be super-user to do this.

2/13: Some of the tests (particular anything that writes to disk) will be easiest on top of an older, simpler file system such as ext2. Modern file systems such as ext3, ReiserFS, etc., are journaling file systems, and hence introduce additional write traffic into the picture. (we'll hear more about journaling later in the semester). That said, if you still can manage on top of these more complex systems, all the better.

2/13: Note that more recent versions of Linux do not use an entirely LRU-like replacement policy.

Overview

In this assignment, you will get your feet just a little bit wet with a computer system. One of the most important parts of computer systems is evaluation. Hence, understanding what it takes to perform such an evaluation is a skill we wish to develop.

What you're going to do: First, you have to pick a platform to study. Any Unix-based system (such as a PC running some version of Linux) is acceptable. For this assignment, please no Windows-based systems, unless you also do some Unix-based system in addition. Second, you're going to run some simple experiments, which you design to bring out various properties of the file system under test. Third, you are going to create some graphs to demonstrate those properties -- call them "empirical proofs". Finally, you will write up what you did.

You are to work alone on this project. Talking to your friends at some level is OK, but this should primarily be an exercise for you. Part of the process is to develop some measurement skills now for later use in your final project, so do a good job here and it will pay off down the road.

More Detail

In this assignment, we're going to explore the inner-workings of the file system. In a Unix-based file system, assume we have the following system calls to work with: open(), close(), read(), write(), lseek(), and fsync(). If you don't know what those system calls do, then use the man pages to find out.

Our main approach is going to be to write little code snippets that exercise the file system in different ways; then, by measuring how long various operations take, we are going to try to make some deductions about what the file system is doing.

Step 0: Platform

Pick a platform you will work upon. Very likely it will be something like a PC running Linux, but please feel free to be adventurous -- it will keep my eyes open when reading your project on a system that is a bit different, e.g., FreeBSD, some ugly old Unix system like AIX, or even Mac OS X. However, please do use a Unix-based system.

Step 1: Timers

The accuracy and granularity of the timer you use will often have a large affect on your measurements. Therefore, you should use the best timer available. Fortunately, on x86 platforms, a highly accurate cycle counter is available. The instruction to use it is known as rdtsc, and it returns a 64-bit cycle count. By knowing the cycle time, one can easily convert the result of rdtsc into a useful time. Other platforms have similar highly-accurate timers available - use them!

Hence, the first thing you should do is: figure out how to use rdtsc or its analogue (you can use google to find out more about it). Once you know how to call it and get a cycle count, convert the result to seconds and measure how long something takes (e.g., a program that calls sleep(10) and exits should run for about 10 seconds. Confirm your results make sense by comparing it to a less accurate but reliable counter such as gettimeofday. Note that confirmation of timer accuracy is hugely important! If you don't trust your timer, how can you trust the results of your measurements?

Step 2: Measuring the File System

After getting our timer in order, we will move on and measure some aspects of the file system proper. All measurements should be done on the local disk of some machine - do not measure the performance of a distributed file system such as AFS, where, for example, your CS account resides. If you aren't using your own machine, you might consider the Crash and Burn lab or just one of the other computer labs in the building.

Through experiments that you design, implement, run, and measure, you are to answer the following questions:

How big is the block size used by the file system to read data? Hint: use reads of varying sizes and plot the time it takes to do such reads. Also, be wary of prefetching effects that often kick in during sequential reads.
During a sequential read of a large file, how much data is prefetched by the file system? Hint: time each read and plot the time per read.
How big is the file cache? Hint: Repeated reads to a group blocks that fit in cache will be very fast; repeated reads to a group of blocks that don't fit in cache will be slow.
How many direct pointers are in the inode? Hint: think about using write() and fsync() to answer this question. Also think about what happens when you extend a file and suddenly an indirect pointer must be allocated -- how many more writes occur at that point?
Hence, in your write-up, you should have one or more graphs which you use to directly answer the questions above. Be critical of yourself -- are the conclusions you draw foolproof? Or are they mere hypotheses?

A major issue with any data collection is: how convincing are your numbers? How do you make them more convincing? How do you deal with experimental noise? etc. Use your common sense and be critical of your numbers -- do they really convince you that you know the answer?

One thing you will undoubtedly do is to use repetition to increase your confidence, i.e., you will take multiple measurements of an event, and compute (for example) an average over many runs instead of the result from just a single experiment. Be careful when computing averages over numbers -- make sure to always first look at all the data. If you don't, you might use an average where an average doesn't make sense.

Step 3: Writing It Up

After you're done with experiments, you'll need to write up what you've done. What should go in your writeup? Here are some tips:
Title: The title should be descriptive and fit in one line across the page.
Author: Right under the title, this says who you are.
Abstract: This is the paper in brief and should state the basic contents and conclusions of the paper. The abstract is not the introduction to the paper (it should be shorter), but is a summary of everything. Read some of the abstracts of papers we've read for class to get a better idea. In general, the abstract is an advertisement that should draw the reader into your paper, without being misleading. It should be complete enough to understand what will be covered in the paper. This is a technical paper and not a mystery novel -- don't be afraid of giving away the ending!
Intro: A short overview of what you did, and what you learned. More motivation than the abstract, and more details. Again, make sure you include your main conclusions.
Methodology: How you measured what you measured. Include something about your timer accuracy here, as well as a description of the platform you are using to the level of detail such that someone else could reproduce the experiment elsewhere.
Results: This section should consist mainly of graphs, addressing each of the questions above. Make sure that graphs have axes labeled (including units). Also make sure to include the code snippets with each graph (or some rough description of them) so we have an idea what exactly you measured. Also, make sure to draw appropriate conclusions about each graph.
Conclusions: Summarize your conclusions here, and talk about what else you have learned in the process.
This paper should be at most 6 pages long (including everything), in 10 point or larger font, in double column format. In your write-up, you should not re-describe the assignment. Your paper must be written using proper English grammar and should have no spelling mistakes.
I also recommend/require the following two tools:
LaTeX Use this for typesetting your document.
gnuplot Use this for making graphs.
Check out ~remzi/public/Example/ for an example of how to use these tools. LaTeX is an excellent system for writing academic/scientific papers with, and it is worth spending some amount of time learning how to use it. Using gnuplot or something like it (e.g., Ploticus ) also makes a lot of sense as these tools produce nice encapsulated postscript (eps) files to use within LaTeX.

Step 4: Enjoying Yourself

Computer systems are complicated, and careful and accurate measurement is a tricky business. Make sure to have fun! How should you do that? Probably by starting early. As always, feel free to ask me questions if you are having trouble. Good luck!