9. Filesystems

SoftSys Lecture Notes, Wednesday 3/3/21 #

Demoscene #

Demoscene is about creating procedural audiovisual animations (called “intros” or “demos”). Artists challenge themselves by constraining how large the executable can be or what hardware their animation runs on.

https://www.youtube.com/watch?v=cjBEgPWT2sQ

If you want to see an insane level of performance optimization, you might enjoy demoscene.

Other videos you can check out:

I/O Performance (Continued from last time) #

One of the simplest command-line utilities is a program called yes. If you run it, you will see it simply print out y over and over again, once per line. (Use Ctrl-C to stop this if you start running it.)

We’re going to try an exercise to see how it performs.

  1. First, install the program pv on your machine by running sudo apt install pv (or the equivalent command for Mac, probably brew install pv).
  2. Let’s benchmark the actual version of yes to see how it performs. Run yes | pv -r > /dev/null to see how fast yes writes. (Again, use Ctrl-C to stop execution.)
  3. Now write your own version of this utility called yes.c. Compile and run it in the same way as above to measure its speed. How does it compare?
  4. Your implementation is probably a bit slower than the built-in yes program, so let’s try to get it a bit faster. Read about the write system call by running man 2 write (on most systems). Try using this to write y repeatedly.
  5. Define a constant in yes.c called COPIES (you can do this by adding a line like #define COPIES 42 at the top of the file). Then modify your implementation so that you create a string containing COPIES copies of y\n (what yes prints by default), and try measuring the speed of your program again.
  6. If you have time, try playing around with the value of COPIES to see what kinds of values help make the performance faster or slower.

Filesystems: Disk Times #

Exercise:

Assume 10 ms random seek time and 4 ms rotational latency. Assume 1 Gb/s transfer rate.

  1. What is the total time to seek a random track, read a random block, and transfer 8 KiB from disk?
  • 14 + 0.065 = 14.065 ms
  1. How much additional time would it take if we transferred 800 KiB instead?
  • 14 + 6.5 = 20.5 ms

Filesystems: Inodes #

Exercise:

  1. In a file system with 48-bit block addresses, how many blocks can be addressed? Express your answer in base 10 scientific notation.
    • 2^48 = 2.81e14
  2. If each block is 8 KiB, what is the total size of all addressable blocks? Express your answer in binary prefix units.
    • 2^48*8KiB = 2^48*8192 = 2.31e18 bytes
  3. How many block addresses can fit in a block?
    • 2^13 * 8 / 48 = 1365
    • 1 KiB = 2^13 bits
  4. If the system uses UNIX-style inodes that contain 12 direct block pointers, what is the biggest file we can address using only the direct pointers?
    • 98304 bytes
  5. What is the biggest file we can address using the direct pointers and the singly indirect pointer?
  6. Bonus question: what is the biggest file we can address using the inode, the singly indirect pointer, and the doubly indirect pointer?