Skip to main content

Crate frozen_core

Crate frozen_core 

Source
Expand description

Latest Version License Tests

§FrozenCore

Custom implementations and core utilities for frozen-lab crates.

§Index

§Notes

[!IMPORTANT] frozen-core is primarily created for frozen-lab projects. External use is discouraged, but not prohibited, given you assume all the risks.

This project is licensed under the Apache-2.0 and MIT License. See the LICENSE-APACHE and LICENSE-MIT file for more details.

Contributions are welcome! Please feel free to submit a PR or open an issue if you have any feedback or suggestions.

[!NOTE] frozen-core contains next to naught AI-generated code. Therefore, any catastrophic bugs or fatal crashes encountered are results of pure & unadulterated skill issues

§FrozenErr

FrozenRes & FrozenErr are custom implementation’s for result and error propagation.

To use the error module, add it as a dependency in your Cargo.toml:

[dependencies]
frozen-core = { version = "0.0.18", features = ["error"] }

§Hints

The hints module provides stable friendly implementations of likely and unlikely branch hints functions.

To use the hints module, add it as a dependency in your Cargo.toml:

[dependencies]
frozen-core = { version = "0.0.18", features = ["hints"] }

§FrozenFile

FrozenFile is a custom implementation of std::fs::File.

To use the ffile module, add it as a dependency in your Cargo.toml:

[dependencies]
frozen-core = { version = "0.0.18", features = ["ffile"] }

FrozenFile is currently available on the following platforms,

PlatformSupport
aarch64-unknown-linux-gnu
x86_64-unknown-linux-gnu
aarch64-pc-windows-msvc
x86_64-pc-windows-msvc
aarch64-apple-darwin
x86_64-apple-darwin

§FrozenMMap

FrozenMMap is a custom implementation of mmap.

To use the fmmap module, add it as a dependency in your Cargo.toml:

[dependencies]
frozen-core = { version = "0.0.18", features = ["fmmap"] }

FrozenMMap is currently available on the following platforms,

PlatformSupport
aarch64-unknown-linux-gnu
x86_64-unknown-linux-gnu
aarch64-pc-windows-msvc
x86_64-pc-windows-msvc
aarch64-apple-darwin
x86_64-apple-darwin

§Crc32

Implementation of CRC32C (Castagnoli polynomial) to compute a 32-bit cyclic redundancy check (CRC) using Castagnoli polynomial, intended for data integrity verification for torn writes and corruption detection.

[!WARNING] We assume little-endian target architecture, as big-endian architectures are not supported

[!IMPORTANT] The generated 32-bit CRC is not cryptographically secure, it’s intended use only is for data integrity in IO ops

To use the crc32 module, add it as a dependency in your Cargo.toml:

[dependencies]
frozen-core = { version = "0.0.18", features = ["crc32"] }

Crc32C is available on following architectures,

ArchitectureSupport
aarch64
x86_64

Look at following benches for the throughout and latency measurements,

ModeSizeTime (ns / µs)Throughput (GiB/s)
1x4 KiB318 ns11.97
2x4 KiB340 ns11.24
4x4 KiB451 ns8.46
1x64 KiB5.44 µs11.23
2x64 KiB5.26 µs11.60
4x64 KiB7.50 µs8.14
1x1 MiB89.80 µs10.88
2x1 MiB90.56 µs10.78
4x1 MiB120.04 µs8.13

Environment used for benching,

  • OS: NixOS (WSL2)
  • Architecture: x86_64
  • Memory: 8 GiB RAM (DDR4)
  • Backend: Hardware (SSE4.2)
  • Rust: rustc 1.86.0 w/ cargo 1.86.0
  • Kernel: Linux 6.6.87.2-microsoft-standard-WSL2
  • CPU: Intel® Core™ i5-10300H @ 2.50GHz (4C / 8T)

§BPool

Lock-free buffer pool used for staging IO buffers.

It offers following backends,

  • Dynamic: fastest, low latency, heap allocated
  • Prealloc: stable under contention, bounded memory, lock free reuse

To use the bpool module, add it as a dependency in your Cargo.toml:

[dependencies]
frozen-core = { version = "0.0.18", features = ["bpool"] }

Following are latency measurements for allocation across different backends and configurations.

[!NOTE] All timings represent allocation + drop (RAII lifecycle)

Single tx latency,

N (Chunks)Dynamic Time (ns / µs)Prealloc Time (ns / µs)
1150 ns262 ns
4163 ns595 ns
16163 ns1.97 µs
64220 ns8.25 µs

Prealloc scaling (batch size),

N (chunks)Time (ns / µs)
1253 ns
81.13 µs
323.97 µs
12814.84 µs

Contention (multi tx),

ThreadsTime (µs)
2132 µs
4243 µs
8519 µs

Blocking behavior (Prealloc),

ScenarioTime (µs)
Pool exhaustion68.6 µs

Fallback (Prealloc -> Dynamic),

N (chunks)Time (ns)
32201 ns
64229 ns
128252 ns

Where value of N is N = 64.

Environment used for benching,

  • OS: NixOS (WSL2)
  • Architecture: x86_64
  • Memory: 8 GiB RAM (DDR4)
  • Rust: rustc 1.86.0 w/ cargo 1.86.0
  • Kernel: Linux 6.6.87.2-microsoft-standard-WSL2
  • CPU: Intel® Core™ i5-10300H @ 2.50GHz (4C / 8T)

§MPSCQ

A lock-free multi-producer single-consumer queue.

To use the mpscq module, add it as a dependency in your Cargo.toml:

[dependencies]
frozen-core = { version = "0.0.18", features = ["mpscq"] }

Following are latency measurements for push, drain, and combined operations,

[!NOTE] All timings represent end-to-end operation cost (including allocation & reclamation)

Single-thread push,

N (ops)Time (ns / µs)
130 ns
8313 ns
642.31 µs
2568.49 µs

Single-thread drain,

N (ops)Time (ns / µs)
137 ns
8263 ns
642.17 µs
2568.23 µs

Push + Drain cycle,

N (ops)Time (ns / µs)
134 ns
8241 ns
642.13 µs
2569.95 µs

Contention (multi-producer push),

ThreadsTime (µs)
2119 µs
4199 µs
8375 µs

Producer + Consumer,

ScenarioTime (µs)
Concurrent pipeline121 µs

Environment used for benching,

  • OS: NixOS (WSL2)
  • Architecture: x86_64
  • Memory: 8 GiB RAM (DDR4)
  • Rust: rustc 1.86.0 w/ cargo 1.86.0
  • Kernel: Linux 6.6.87.2-microsoft-standard-WSL2
  • CPU: Intel® Core™ i5-10300H @ 2.50GHz (4C / 8T)

§FrozenPipe

An high throughput asynchronous IO pipeline for chunk based storage, it uses batches to write requests and flushes them in the background, while providing durability guarantees via epochs.

To use the fpipe module, add it as a dependency in your Cargo.toml:

[dependencies]
frozen-core = { version = "0.0.18", features = ["fpipe"] }