|
1 | 1 | # blockio |
2 | 2 |
|
3 | | -This packages defines an abstract interface for batched, asynchronous I\/O, |
4 | | -for use with the abstract interface for file system I\/O defined by the |
5 | | -[fs-api](https://hackage.haskell.org/package/fs-api) package. |
| 3 | +Perform batches of disk I/O operations. Performing batches of disk I/O can lead |
| 4 | +to performance improvements over performing each disk I/O operation |
| 5 | +individually. Performing batches of disk I/O *concurrently* can lead to an even |
| 6 | +bigger performance improvement depending on the implementation of batched I/O. |
6 | 7 |
|
7 | | -The /sim/ sub-library of this package defines /simulated/ batched, asynchronous I\/O |
8 | | -for use with the [fs-sim](https://hackage.haskell.org/package/fs-sim) package. |
| 8 | +The batched I/O functionality in the library is separated into an *abstract |
| 9 | +interface* and *implementations* of that abstract interface. The advantage of |
| 10 | +programming against an abstract interface is that code can be agnostic to the |
| 11 | +implementation of the interface, allowing implementations to be freely swapped |
| 12 | +out. The library provides multiple implementations of batched I/O: |
| 13 | +platform-dependent implementations using the *real* file system (using |
| 14 | +asynchronous I/O), and a simulated implementation for testing purposes. |
| 15 | + |
| 16 | +See the `System.FS.BlockIO` module for an example of how to use the library. |
| 17 | + |
| 18 | +On Linux systems the *real* implementation is backed by |
| 19 | +[blockio-uring](https://hackage.haskell.org/package/blockio-uring), a library |
| 20 | +for asynchronous I/O that achieves good performance when performing batches |
| 21 | +concurrently. On Windows and MacOS systems the *real* implementation currently |
| 22 | +simply performs each I/O operation sequentially, which should achieve about the |
| 23 | +same performance as using non-batched I/O, but the library could be extended |
| 24 | +with asynchronous I/O implementations for Windows and MacOS as well. The |
| 25 | +simulated implementation also performs each I/O operation sequentially. |
| 26 | + |
| 27 | +As mentioned before, the batched I/O functionality is separated into an |
| 28 | +*abstract interface* and *implementations* of that abstract interface. The |
| 29 | +advantage of programming against an abstract interface is that code can be |
| 30 | +agnostic to the implementation of the interface. For example, we could run code |
| 31 | +in production using the real file system, but we could also run the same code in |
| 32 | +a testing environment using a simulated file system. We could even switch from a |
| 33 | +default implementation to a more performant implementation in production if the |
| 34 | +performant implementation is available. Lastly, the abstract interface allows us |
| 35 | +to program against the file system in a uniform manner across different |
| 36 | +platforms, i.e., operating systems. |
| 37 | + |
| 38 | +The `blockio` library defines the abstract interface for batched I/O. The |
| 39 | +library is an extension of the |
| 40 | +[fs-api](https://hackage.haskell.org/package/fs-api) library, which defines an |
| 41 | +abstract interface for (basic) file system I/O. Both `blockio` and `fs-api` |
| 42 | +provide an implementation of their interfaces using the real file system in |
| 43 | +`IO`. |
| 44 | + |
| 45 | +The `blockio:sim` sub-library defines an implementation of the abstract |
| 46 | +interface from `blockio` that *simulates* batched I/O. This sub-library is an |
| 47 | +extension of the [fs-sim](https://hackage.haskell.org/package/fs-sim) library, |
| 48 | +which defines an implementation of the abstract interface from `fs-api` that |
| 49 | +simulates (basic) file system I/O. |
0 commit comments