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
110 changes: 110 additions & 0 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Rust

on: [push, pull_request]

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
build:
- pinned
- stable
- stable-32
- stable-mips
- beta
- nightly
- macos
- win-msvc
- win-gnu
include:
- build: pinned
os: ubuntu-latest
rust: stable
- build: stable
os: ubuntu-latest
rust: stable
- build: stable-32
os: ubuntu-latest
rust: stable
target: i686-unknown-linux-gnu
- build: stable-mips
os: ubuntu-latest
rust: stable
target: mips64-unknown-linux-gnuabi64
- build: beta
os: ubuntu-latest
rust: beta
- build: nightly
os: ubuntu-latest
rust: nightly
- build: macos
os: macos-latest
rust: stable
- build: win-msvc
os: windows-2019
rust: stable
- build: win-gnu
os: windows-2019
rust: stable-x86_64-gnu
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --verbose --all
bench:
name: Bench
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: bench
args: --all

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ target
Cargo.lock
.vimsession
core
test.out
flamegraph.svg
perf.out
check.out
perf.data
perf.data.old
28 changes: 17 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
[package]
name = "xorfilter-rs"
version = "0.2.0"
authors = ["prataprc <prataprc@gmail.com>"]
edition = "2018"
version = "0.4.0"
description = "Xor Filters: Faster and Smaller Than Bloom and Cuckoo Filters"
license = "Apache-2.0"
repository = "https://github.com/bnclabs/xorfilter"
documentation = "https://docs.rs/xorfilter-rs"
keywords = ["xorfilter", "bloom", "bitmap", "data-structures"]
categories = ["algorithms", "database", "data-structures"]
homepage = "https://github.com/bnclabs/xorfilter"
repository = "https://github.com/bnclabs/xorfilter"
authors = ["prataprc <prataprc@gmail.com>"]
license = "Apache-2.0"
edition = "2018"
readme = "README.md"

[profile.release]
debug = true

[profile.bench]
debug = true

[lib]
name = "xorfilter"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[workspace]
members = ["benches"]

[dependencies]

[dev-dependencies]
rand = "0.6.4"
criterion = "0.3"

[[bench]]
name = "xor_bench"
harness = false
criterion = "0.3"
31 changes: 22 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
release:
cargo clean;
cargo +stable build;
cargo +nightly build;
cargo +stable doc;
cargo +nightly clippy --all-targets --all-features;
cargo +nightly test;
cargo +stable test;
cargo +nightly bench;
build:
# ... build ...
cargo +nightly build
cargo +stable build
# ... test ...
cargo +nightly test --no-run
cargo +stable test --no-run
# ... bench ...
cargo +nightly bench --no-run
# ... doc ...
cargo +nightly doc
cargo +stable doc
# ... meta commands ...
cargo +nightly clippy --all-targets --all-features
flamegraph:
echo "nothing todo"
prepare:
check.sh
perf.sh
clean:
cargo clean
rm -f check.out perf.out flamegraph.svg perf.data perf.data.old
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
![](https://github.com/bnclabs/xorfilter/workflows/simple-build-test/badge.svg)

# Rust library implementing xor filters
Rust library implementing xor filters
-------------------------------------

Implementation of [Xor Filters: Faster and Smaller Than Bloom and Cuckoo Filters](https://arxiv.org/abs/1912.08258)
in [rust-lang](https://www.rust-lang.org/), Journal of Experimental Algorithmics (to appear).
Expand Down Expand Up @@ -41,12 +42,14 @@ for key in 0..lookup {
}
```

### Open issues
Open issues
-----------

* [ ] Serialize / Deserialize Xor8 type.
* [ ] Incrementally adding keys to a pre-built Xor8 instance.

### Benchmarks
Benchmarks
----------

Benchmark number for original golang implementation.

Expand Down Expand Up @@ -78,7 +81,24 @@ bits per entry 9.864 bits
false positive rate 0.3866%
```

### Resources
Useful links
------------

* [Xor Filters: Faster and Smaller Than Bloom and Cuckoo Filters](https://arxiv.org/abs/1912.08258)
* [Blog post by Daniel Lemire](https://lemire.me/blog/2019/12/19/xor-filters-faster-and-smaller-than-bloom-filters/)


Contribution
------------

* Simple workflow. Fork - Modify - Pull request.
* Before creating a PR,
* Run `make build` to confirm all versions of build is passing with
0 warnings and 0 errors.
* Run `check.sh` with 0 warnings, 0 errors and all testcases passing.
* Run `perf.sh` with 0 warnings, 0 errors and all testcases passing.
* [Install][spellcheck] and run `cargo spellcheck` to remove common spelling mistakes.
* [Developer certificate of origin][dco] is preferred.

[dco]: https://developercertificate.org/
[spellcheck]: https://github.com/drahnr/cargo-spellcheck
69 changes: 18 additions & 51 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
0.4.0
=====

* package maintanence.

0.3.0
=====

* Xor8 to bytes and vice-versa conversion.
* implement Default trait.
* implement mkit's IntoCbor and FromCbor traits for Cbor serialization.
* improve test cases.
* use criterion for benchmark.
* clippy fixes.
* ci scripts.

0.2.0
=====

Expand All @@ -11,55 +27,6 @@

* First release

Code Review checklist
=====================

* [ ] Check and confirm dead-code.
* [ ] Check and confirm ignored test cases.
* [ ] Replace panic!(), assert!(), unreachable!(), unimplemented!(),
macros with Err(Error).
* [ ] Avoid println!() macro in production code.
* [ ] Validate the usage of:
* [ ] unwrap() calls.
* [ ] ok() calls on Result/Option types.
* [ ] unsafe { .. } blocks.
* [ ] Trim trait constraits for exported types, exported functions
and methods.

Release Checklist
=================
Refer to [release-checklist][release-checklist].

* Bump up the version:
* __major__: backward incompatible API changes.
* __minor__: backward compatible API Changes.
* __patch__: bug fixes.
* Travis-CI integration.
* Cargo checklist
* cargo +stable build; cargo +nightly build
* cargo +stable doc
* cargo +nightly clippy --all-targets --all-features
* cargo +nightly test; cargo +stable test
* cargo +nightly bench;
* cargo fix --edition --all-targets
* Cargo publish the new version.
* Create a git-tag for the new version.
* Badges
* Build passing, Travis continuous integration.
* Code coverage, codecov and coveralls.
* Crates badge.
* Downloads badge.
* License badge.
* Rust version badge.
* Maintenance-related badges based on isitmaintained.com
* Documentation.
* Gitpitch.
* Targets.
* RHEL
* SUSE
* Debian
* Centos
* Ubuntu
* Mac-OS
* Windows
* amazon-aws
* Raspberry-pi
[release-checklist]: https://prataprc.github.io/rust-crates-release-checklist.html
24 changes: 24 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "xor-benches"
version = "0.1.0"
authors = ["Alex Mikhalev <alex@sci-blog.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
bench = false

[[bench]]
name = "filters"
harness = false
path = "src/filters.rs"

[profile.bench]
debug = true

[dependencies]
criterion = "0.3.4"
xorfilter-rs = {version = "*",path = ".."}
pdatastructs = "0.6.0"
iai = "0.1"
10 changes: 10 additions & 0 deletions benches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Run criterion benchmarks and build flamegraph

```
cargo flamegraph --bench filters -- --bench

```

```
cargo bench --manifest-path benches/Cargo.toml
```
23 changes: 23 additions & 0 deletions benches/src/fhash_ahash.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use std::collections::{HashMap, hash_map::RandomState};
use std::hash::BuildHasher;

fn test_with<S: BuildHasher + Default>() {
for _ in 0..10 {
let mut map: HashMap<i32,i32,S> = HashMap::with_capacity_and_hasher(1000_0000, Default::default());
let now = std::time::Instant::now();
for key in 0..1000_0000 {
map.insert(key, key);
}
let elapsed = now.elapsed();
println!("{:?}", elapsed);
}
}

fn main() {
println!("std:");
test_with::<RandomState>();
println!("ahash:");
test_with::<ahash::RandomState>();
println!("fxhash:");
test_with::<fxhash::FxBuildHasher>()
}
Loading