Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,48 @@ jobs:
- name: Build
run: cargo hack build --verbose --release --feature-powerset --exclude-features loom
- name: Tests
run: cargo hack test --verbose --release --feature-powerset --exclude-features loom
run: cargo hack test --verbose --release --lib --bins --tests --feature-powerset --exclude-features loom
- name: Documentation tests
run: cargo test --verbose --release --doc
- name: No default hasher
run: cargo test --verbose --release --lib --bins --tests --no-default-features
- name: Non rand default seed
run: cargo test --lib --no-default-features --features default-hasher hasher::test
- name: Non rand without std
run: cargo check --no-default-features --features default-hasher

- name: Install thumb target
run: rustup target add thumbv7em-none-eabi
- name: 32-bit embedded check
run: cargo check --target thumbv7em-none-eabi --no-default-features

- name: Loom build
run: cargo hack build --lib --bins --tests --feature-powerset --exclude-features serde,rand,default
run: cargo build --lib --bins --tests --no-default-features --features loom,default-hasher
- name: Loom tests
run: cargo hack test loom --lib --bins --tests --feature-powerset --exclude-features serde,rand,default
run: cargo test loom --lib --bins --tests --no-default-features --features loom,default-hasher

msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: "1.70"
toolchain: "1.71"
override: true
- name: Install cargo-hack
run: cargo install cargo-hack --version 0.6.37 --force --locked
- name: Build
run: cargo hack build --verbose --release --feature-powerset --exclude-features loom
- name: Tests
run: cargo hack test --verbose --release --feature-powerset --exclude-features loom
run: cargo hack test --verbose --release --lib --bins --tests --feature-powerset --exclude-features loom
- name: Documentation tests
run: cargo test --verbose --release --doc
- name: No default hasher
run: cargo test --verbose --release --lib --bins --tests --no-default-features
- name: Non rand default seed
run: cargo test --lib --no-default-features --features default-hasher hasher::test
- name: Non rand without std
run: cargo check --no-default-features --features default-hasher

- name: Install thumb target
run: rustup target add thumbv7em-none-eabi
Expand Down
47 changes: 16 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "hyperloglockless"
version = "0.5.0"
edition = "2021"
rust-version = "1.70.0"
rust-version = "1.71.0"
authors = ["tomtomwombat"]
description = "High-performance HyperLogLog with bias correction and full concurrency support."
license = "MIT OR Apache-2.0"
Expand All @@ -16,21 +16,21 @@ readme = "README.md"
maintenance = { status = "actively-developed" }

[features]
default = ["std", "rand"]
default = ["std", "default-hasher", "rand"]
std = ["portable-atomic/std"]
loom = ["dep:loom"]
rand = ["std", "dep:rand"]
serde = ["dep:serde", "twox-hash/serialize", "portable-atomic/serde"]
default-hasher = ["dep:rapidhash"]
rand = ["default-hasher", "std", "dep:rand"]
serde = ["dep:serde", "portable-atomic/serde"]

[dependencies]
foldhash = { version = "0.2.0", default-features = false }
loom = { version = "0.7.2", optional = true }
rapidhash = { version = "4.5.1", default-features = false, optional = true }
rand = { version = "0.9.0", optional = true }
serde = { version = "1.0.203", features = ["derive"], optional = true }
twox-hash = { version = "1.6.3", default-features = false }
libm = "0.2"
portable-atomic = { version = "1.13.1", default-features = false, features = ["fallback"] }

[dev-dependencies]
fastrand = "2.3.0"
serde_cbor = "0.11.2"
serde_cbor = "0.11.2"
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ let count = hll.count(); // ~27
assert_eq!(hll.len(), 1 << precision); // 16384 bytes
```

The default hasher is `twox_hash` because of its portability, MSRV, and reasonable speed. However, you may use any hasher:
The default hasher uses rapidhash's `quality` flavor, which is designed for low collision rates in algorithms such as HyperLogLog. However, you may use any hasher:
```rust
use hyperloglockless::HyperLogLog;
use foldhash::fast::RandomState;
use std::collections::hash_map::RandomState;

let hll = HyperLogLog::with_hasher(14, RandomState::default());
```
Expand Down Expand Up @@ -93,7 +93,8 @@ Below measures and compares the amortized insert performance of `hyperloglockles

## Available Features

- **`rand`** - Enabled by default, this has the `DefaultHasher` source its random state using `thread_rng()` instead of hardware sources. Getting entropy from a user-space source is considerably faster, but requires additional dependencies to achieve this. Disabling this feature by using `default-features = false` makes `DefaultHasher` source its entropy using `foldhash`, which will have a much simpler code footprint at the expense of speed.
- **`default-hasher`** - Enabled by default. Provides Rapidhash's quality hasher as the default type for each sketch and does not require `std`. When enabled without `rand`, it uses Rapidhash's own random state for the default seed. Disabling this feature removes both the `rand` and `rapidhash` dependencies; sketches then require an explicit hasher type and can still use `new` when that hasher implements `Default`.
- **`rand`** - Enabled by default. Implies `default-hasher` and `std`, and uses `rand`'s thread-local RNG to seed the default hasher instead of Rapidhash's random state.
- **`serde`** - HyperLogLogs implement `Serialize` and `Deserialize` when possible.
- **`loom`** - `AtomicHyperLogLog`s use [loom](https://github.com/tokio-rs/loom) atomics, making it compatible with loom testing.

Expand Down
Loading
Loading