Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Quick Start Tutorial

Step by step workshop building an AFIO-based key-value store
1. World's simplest named blob store in STL iostreams
2. World's simplest named blob store in AFIO (synchronous)
3. World's simplest named blob store in AFIO (asynchronous)
The problems with this naive design
4. Second attempt at a key-value store: How to implement atomic value updates and therefore Atomicity, Consistency, Isolation and Durability
The performance of and problems with this second generation design
5. Third attempt at a key-value store: Thinking like a filing system
The final named blob store design
The performance of and problems with this third generation design
Example mini-programs written using AFIO
Hello World, asynchronously!
A less toy example: Concatenating files
Achieving atomicity on the filing system
Handling races on the filing system
What performance benefit does asynchronous file i/o bring me? A demonstration

So why bother with Boost.AFIO? What's wrong with the STL iostreams and Filesystem?

The answer is that there is nothing wrong with either for 95% of use cases. Performance of both is pretty good in fact most of the time — which actually isn't that surprising as C++ is a pay-for-what-you-use systems language, and you'll see how well STL iostreams does later on in this tutorial.

However a surprising amount of production code out there is highly unreliable when used on a filing system experiencing rapid change, or even just a filing system mounted on a network. In many ways it is when your code needs to grow up from assuming a never changing static filesystem into a more realistic model is when you ought to reach AFIO which has hopefully abstracted away all those tedious platform specific and filing system specific quirks for you.

The quick start tutorial is broken into two sections:

  1. A step by step workshop in building an AFIO program which can concurrently read/write an indexed blobstore. This workshop was presented at CppCon 2015 and the slides and materials can be found at <TBD LINK>. Issues covered:
    • Files being renamed, created or deleted by others when you are using them.
    • Directories being renamed, created or deleted by others when you are using them.
    • Windows only: how to correctly delete a directory tree on Windows, and why almost every implementation of directory tree deletion for Windows is unreliable.
    • Techniques for avoiding filing system races:
      • Inode checking
      • Lock files
      • Atomic renames
      • Never use absolute paths
  2. Real world sample mini-programs written using AFIO which show various filing system algorithms and strategies in action.
    • Hello world
    • Concatenating files
    • Atomicity on the filing system
    • Races on the filing system
    • Find regular expression in files in directory tree

PrevUpHomeNext