Log-Structured File Systems
Computers Circa 1991
-
Disk bandwidth is improving rapidly, meaning the operating system can stream reads or writes to the disk faster.
-
Computers have more memory. Up to 128 MB! (Whoa.)
-
And, alas, disk seek times are …
Using What We Got
So, if we can solve this pesky seek issue we can utilize growing disk bandwidth to improve file system performance.
-
Oh, by the way: we’ve got a bunch of spare memory lying around. Might that be useful?
Use a Cache!
-
Use a cache! Or, put a smaller, faster thing in front of it.
-
In the case of the file system the smaller, faster thing is memory.
-
We call the memory used to cache file system data the buffer cache.
A New Hope
-
With a large cache, we should be able to avoid doing almost any disk reads.
-
But we will still have to do disk writes, but the cache will still help collect small writes in memory until we can do one larger write.
Log Structured File Systems
Invented and implemented at Stanford by then-faculty John Ousterhout and now-faculty Mendel Rosenblum.
-
Great… um… how do we do that?
A Normal Write
Example: let’s say we want to change an existing byte in a file.
-
Seek to read the inode map.
-
Seek to read the inode.
-
Seek to write (modify) the data block.
-
Seek to write (update) the inode.
A Cached-Read Write
Let’s assume that our big friendly cache is going to soak up the reads.
-
*Seek to read the inode map.*
-
*Seek to read the inode.*
-
Seek to write (modify) the data block.
-
Seek to write (update) the inode.
I See What You Did There
Elegant solution! Reads are handled by the cache. Writes can stream to the disk at full bandwidth due to short seeks to append to the log.
-
But some thorny details to address.
When Do Writes Happen?
Want to stream as many writes to disk together as possible to maximize usage of disk bandwidth.
-
When the user calls
sync
,fsync
or when blocks are evicted from the buffer cache.
Locating LFS inodes
-
It stored the inode map in a fixed location on disk.
-
inodes are just appended to the log and so they can move!
-
Yep, it logs the inode map.
LFS metadata
-
We can log that stuff too!
As the Log Turns
-
Probably a lot of unused space earlier in the log due to overwritten inodes, data blocks, etc.
-
Clean the log by identifying empty space and compacting used blocks.
The Devil’s in the Cleaning
-
LFS seems like an incredibly great idea…
-
(Then it becomes a debatably great idea…)
Cleaning Questions
-
Probably when the system is idle, which may be a problem on systems that don’t idle much.
-
Large segments amortize the cost to read and write all of the data necessary to clean the segment.
-
…but small segments increase the probability that all blocks in a segment will be "dead", making cleaning trivial.
-
Cleaner overhead is very workload-dependent, making it difficult to reason about the performance of log-structure file system. (And easy to fight about their performance!)
Reading Questions
Let’s say that the cache does not soak up as many reads as we were hoping.
-
Block allocation is extremely discontiguous, meaning that reads may seek all over the disk.
Why Read A Research Paper?
-
Researchers have some great ideas about how to improve computer systems!
-
Many times the design principles apply outside of the specific project described in the paper.
-
-
Both academic and industrial research labs publish papers.
-
Frequently the best/only way to find out details about exciting production systems in use by companies like Google, Microsoft, Facebook, etc.
-
-
Because reading the code takes way too long!
Technology Trending
Forget the feature factory. A lot of research in computer systems is driven by hardware changes and other technology trends which both expose problems with existing systems and create new opportunities for better systems.
-
End of Moore’s Law scaling and the rise of multicore processors.
-
Integration of Flash into the storage hierarchy.
-
Cloud computing!
-
Prevalent and powerful mobile battery-powered devices such as smartphones.
-
More users interacting with multiple devices: smartphones, tablets, laptops, desktops.
-
"Smart dust" and the "Internet of Things".
-
Fast networks everywhere.
-
1,000 things I’ve missed…