MyNixOS website logo
Description

Random file access methods, supporting application-level page cache.

random-access-file README

This package is aimed to provide some number of different implementations of random file access methods with the same interface.

It can be of use for implementing multithread read-write random access for large files, for example for DB engines.

The following implementations are provided:

  • Simple: trivial wrapper around standard System.IO calls. Created mostly for demonstrative purposes. Specific thing about System.IO calls is that they work with one Handle per file, and that Handle contains a pointer to current position in the file. So it is not possible for several threads to read or write to different positions in the file. This implementation is made thread-safe by adding a global per-file lock: several threads can read and/or write to different positions of the file, but all access will be serialized.
  • Threaded: file access using Posix pread(3), pwrite(3) calls. This implementation is thread-safe. It is using block-level locks; each block can be accessed for write by single thread, or for read by many threads. Size of blocks being locked is adjustable.
  • MMaped: file access using mmap(2) call. This implementation is thread-safe. It is using block-level locks also.
  • Cached: File access using application-level page cache, which can be used over Threaded or MMaped file access. Size of cache pages and capacity of the cache are adjustable. Performance of this implementation depends very seriously on your usage pattern and page size.

Benchmark results

Benchmark random-access-file-benchmark: RUNNING...
benchmarking main/simple
time                 691.1 ms   (-610.8 ms .. 1.689 s)
                     0.639 R²   (0.044 R² .. 1.000 R²)
mean                 1.781 s    (1.088 s .. 2.106 s)
std dev              543.2 ms   (192.5 ms .. 732.0 ms)
variance introduced by outliers: 73% (severely inflated)

benchmarking main/threaded
time                 228.5 ms   (196.1 ms .. 248.2 ms)
                     0.993 R²   (0.978 R² .. 1.000 R²)
mean                 250.5 ms   (239.5 ms .. 257.1 ms)
std dev              11.31 ms   (3.916 ms .. 16.04 ms)
variance introduced by outliers: 16% (moderately inflated)

benchmarking main/mmaped
time                 166.0 ms   (147.6 ms .. 182.9 ms)
                     0.989 R²   (0.963 R² .. 1.000 R²)
mean                 162.5 ms   (157.6 ms .. 168.0 ms)
std dev              7.960 ms   (4.764 ms .. 11.38 ms)
variance introduced by outliers: 12% (moderately inflated)

benchmarking main/cached/threaded
time                 1.272 s    (575.8 ms .. 1.865 s)
                     0.951 R²   (0.925 R² .. 1.000 R²)
mean                 1.517 s    (1.365 s .. 1.626 s)
std dev              150.9 ms   (64.02 ms .. 207.5 ms)
variance introduced by outliers: 23% (moderately inflated)

benchmarking main/cached/mmaped
time                 199.2 ms   (78.98 ms .. 332.2 ms)
                     0.863 R²   (0.708 R² .. 1.000 R²)
mean                 237.7 ms   (190.4 ms .. 285.1 ms)
std dev              62.14 ms   (31.83 ms .. 85.03 ms)
variance introduced by outliers: 58% (severely inflated)

Benchmark random-access-file-benchmark: FINISH
Metadata

Version

0.1.0.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows