BLART
BLART is an implementation of an adaptive radix tree, used as backing for map and set data structures. Adaptive radix trees offer great space efficiency and performance on keys that decompose into byte strings.
Example
Here is an example of using the TreeMap type (blatantly stolen from the standard library):
use TreeMap;
// type inference lets us omit an explicit type signature (which
// would be `TreeMap<&str, &str>` in this example).
let mut movie_reviews: = new;
// review some movies.
let _ = movie_reviews.try_insert.unwrap;
let _ = movie_reviews.try_insert.unwrap;
let _ = movie_reviews.try_insert.unwrap;
let _ = movie_reviews.try_insert.unwrap;
// check for a specific one.
if !movie_reviews.contains_key
// oops, this review has a lot of spelling mistakes, let's delete it.
movie_reviews.remove;
// look up the values associated with some keys.
let to_find = ;
for movie in &to_find
// Look up the value for a key (will panic if the key is not found).
println!;
// iterate over everything.
for in &movie_reviews
Documentation
Testing
Miri
Currently we're using some specific crates (sptr and in the future back to core::ptr::*) to ensure that we're compatible with Strict Provenance. The following MIRIFLAGS setup should enable checking to make sure that we're compatible.
MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check"
I think this is useful because we're doing some pointer times with our tagged pointers implementation, mutating the contents of the pointer to store bits of data.
Fuzzing
To run the fuzzer I use the command:
&&
This will run the fuzzer for a total of 3600 seconds (1 hour), using 8 jobs (half of the total number of cores on my dev box), and using the address sanitizer. The cmin command is used to compact the corpus after generating new entries.
Coverage
To generate coverage data from fuzzing corpus:
To generate an HTML report of line-level coverage:
TARGET_TRIPLE=""
View the cov.html in the browser. To see a summary of coverage, broken down by file:
TARGET_TRIPLE=""
|
Benchmarks
To run the benchmarks, install cargo-criterion, then run:
or
If you get a "Permission denied" error, update perf_event_paranoid:
For further details please take a look at the following link.
Profiling
I use a somewhat realistic benchmark: counting words in a text file. To get started, download a text file like:
Then build the word count example using the profiling profile:
RUSTFLAGS="-C force-frame-pointers=yes"
Then run the count words workload on the downloaded data while profiling:
Mutation Testing
cargo-mutants helps you improve your program's quality by finding places where bugs could be inserted without causing any tests to fail.
To get the initial list of failed mutants, run:
To iterate on an existing mutants.out directory, update the code with more tests and run:
If you want to run mutants for a specific file, use:
If you have cargo-nextest installed, you can add --test-tool=nextest to the CLI invocations.
To get the current list of mutants:
|
The sort call is useful to group files together.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.