AFIO on GitHub |
CTest summary dashboard |
Linux and MacOS CI: | Windows CI: |
\code
namespace afio = AFIO_V2_NAMESPACE;
// Make me a 1 trillion element sparsely allocated integer array!
afio::mapped_file_handle mfh = afio::mapped_temp_inode().value();
// On an extents based filing system, doesn't actually allocate any physical
// storage but does map approximately 4Tb of all bits zero data into memory
mfh.truncate(1000000000000ULL*sizeof(int));
// Create a typed view of the one trillion integers
afio::algorithm::mapped_view |
\code namespace afio = AFIO_V2_NAMESPACE; // Create an asynchronous file handle afio::io_service service; afio::async_file_handle fh = afio::async_file(service, {}, "testfile.txt", afio::async_file_handle::mode::write, afio::async_file_handle::creation::if_needed).value(); // Resize it to 1024 bytes truncate(fh, 1024).value(); // Begin to asynchronously write "hello world" into the file at offset 0, // suspending execution of this coroutine until completion and then resuming // execution. Requires the Coroutines TS. alignas(4096) char buffer[] = "hello world"; co_await co_write(fh, {{{buffer, sizeof(buffer)}}, 0}).value(); \endcode |
Why you might need AFIO |
||
---|---|---|
Manufacturer claimed 4Kb transfer latencies for the physical hardware: - Spinning rust hard drive latency @ QD1: **9000us** - SATA flash drive latency @ QD1: **800us** - NVMe flash drive latency @ QD1: **300us** - RTT UDP packet latency over a LAN: **60us** - NVMe Optane drive latency @ QD1: **60us** - `memcpy(4Kb)` latency: **5us** (main memory) to **1.3us** (L3 cache) - RTT PCIe latency: **0.5us** | 100% read QD1 4Kb direct transfer latencies for the software with AFIO: - < 99% spinning rust hard drive latency: Windows **187,231us** FreeBSD **9,836us** Linux **26,468us** - < 99% SATA flash drive latency: Windows **290us** Linux **158us** - < 99% NVMe drive latency: Windows **37us** FreeBSD **70us** Linux **30us** | 75% read 25% write QD4 4Kb direct transfer latencies for the software with AFIO: - < 99% spinning rust hard drive latency: Windows **48,185us** FreeBSD **61,834us** Linux **104,507us** - < 99% SATA flash drive latency: Windows **1,812us** Linux **1,416us** - < 99% NVMe drive latency: Windows **50us** FreeBSD **143us** Linux **40us** |