Skip to content

Unrecord #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
330 changes: 151 additions & 179 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions benches/interval_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn write_interval_log_1k_hist_10k_value(b: &mut Bencher) {
let mut rng = rand::rngs::SmallRng::from_entropy();

for _ in 0..1000 {
let mut h = Histogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap();
let mut h = Histogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap();

for v in RandomVarintEncodedLengthIter::new(&mut rng).take(10_000) {
h.record(v).unwrap();
Expand Down Expand Up @@ -56,7 +56,7 @@ fn parse_interval_log_1k_hist_10k_value(b: &mut Bencher) {
let mut rng = rand::rngs::SmallRng::from_entropy();

for _ in 0..1000 {
let mut h = Histogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap();
let mut h = Histogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap();

for v in RandomVarintEncodedLengthIter::new(&mut rng).take(10_000) {
h.record(v).unwrap();
Expand Down
28 changes: 14 additions & 14 deletions benches/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod rand_varint;

#[bench]
fn record_precalc_random_values_with_1_count_u64(b: &mut Bencher) {
let mut h = Histogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap();
let mut h = Histogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap();
let mut indices = Vec::<u64>::new();
let mut rng = rand::rngs::SmallRng::from_entropy();

Expand All @@ -34,15 +34,15 @@ fn record_precalc_random_values_with_1_count_u64(b: &mut Bencher) {

#[bench]
fn record_precalc_random_values_with_max_count_u64(b: &mut Bencher) {
let mut h = Histogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap();
let mut h = Histogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap();
let mut indices = Vec::<u64>::new();
let mut rng = rand::rngs::SmallRng::from_entropy();

// store values in an array and re-use so we can be sure to hit the overflow case

for v in RandomVarintEncodedLengthIter::new(&mut rng).take(1_000_000) {
indices.push(v);
h.record_n(v, u64::max_value()).unwrap();
h.record_n(v, u64::MAX).unwrap();
}

b.iter(|| {
Expand All @@ -55,7 +55,7 @@ fn record_precalc_random_values_with_max_count_u64(b: &mut Bencher) {

#[bench]
fn record_correct_precalc_random_values_with_1_count_u64(b: &mut Bencher) {
let mut h = Histogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap();
let mut h = Histogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap();
let mut indices = Vec::<u64>::new();
let mut rng = rand::rngs::SmallRng::from_entropy();

Expand All @@ -73,7 +73,7 @@ fn record_correct_precalc_random_values_with_1_count_u64(b: &mut Bencher) {

#[bench]
fn record_random_values_with_1_count_u64(b: &mut Bencher) {
let mut h = Histogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap();
let mut h = Histogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap();
let mut rng = rand::rngs::SmallRng::from_entropy();

// This should be *slower* than the benchmarks above where we pre-calculate the values
Expand All @@ -89,35 +89,35 @@ fn record_random_values_with_1_count_u64(b: &mut Bencher) {
#[bench]
fn add_precalc_random_value_1_count_same_dimensions_u64(b: &mut Bencher) {
do_add_benchmark(b, 1, || {
Histogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap()
Histogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap()
})
}

#[bench]
fn add_precalc_random_value_max_count_same_dimensions_u64(b: &mut Bencher) {
do_add_benchmark(b, u64::max_value(), || {
Histogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap()
do_add_benchmark(b, u64::MAX, || {
Histogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap()
})
}

#[bench]
fn add_precalc_random_value_1_count_different_precision_u64(b: &mut Bencher) {
do_add_benchmark(b, 1, || {
Histogram::<u64>::new_with_bounds(1, u64::max_value(), 2).unwrap()
Histogram::<u64>::new_with_bounds(1, u64::MAX, 2).unwrap()
})
}

#[bench]
fn add_precalc_random_value_max_count_different_precision_u64(b: &mut Bencher) {
do_add_benchmark(b, u64::max_value(), || {
Histogram::<u64>::new_with_bounds(1, u64::max_value(), 2).unwrap()
do_add_benchmark(b, u64::MAX, || {
Histogram::<u64>::new_with_bounds(1, u64::MAX, 2).unwrap()
})
}

#[bench]
fn subtract_precalc_random_value_1_count_same_dimensions_u64(b: &mut Bencher) {
do_subtract_benchmark(b, 1, || {
Histogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap()
Histogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap()
})
}

Expand All @@ -131,7 +131,7 @@ fn do_subtract_benchmark<F: Fn() -> Histogram<u64>>(
count_at_each_addend_value: u64,
addend_factory: F,
) {
let mut accum = Histogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap();
let mut accum = Histogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap();
let mut subtrahends = Vec::new();
let mut rng = rand::rngs::SmallRng::from_entropy();

Expand Down Expand Up @@ -160,7 +160,7 @@ fn do_add_benchmark<F: Fn() -> Histogram<u64>>(
count_at_each_addend_value: u64,
addend_factory: F,
) {
let mut accum = Histogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap();
let mut accum = Histogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap();
let mut addends = Vec::new();
let mut rng = rand::rngs::SmallRng::from_entropy();

Expand Down
24 changes: 12 additions & 12 deletions benches/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ fn serialize_small_sparse_v2(b: &mut Bencher) {
#[bench]
fn serialize_medium_dense_v2(b: &mut Bencher) {
// 56320 counts
do_serialize_bench(b, &mut V2Serializer::new(), 1, u64::max_value(), 3, 1.5)
do_serialize_bench(b, &mut V2Serializer::new(), 1, u64::MAX, 3, 1.5)
}

#[bench]
fn serialize_medium_sparse_v2(b: &mut Bencher) {
// 56320 counts
do_serialize_bench(b, &mut V2Serializer::new(), 1, u64::max_value(), 3, 0.1)
do_serialize_bench(b, &mut V2Serializer::new(), 1, u64::MAX, 3, 0.1)
}

#[bench]
fn serialize_large_dense_v2(b: &mut Bencher) {
// 6291456 buckets
do_serialize_bench(b, &mut V2Serializer::new(), 1, u64::max_value(), 5, 1.5)
do_serialize_bench(b, &mut V2Serializer::new(), 1, u64::MAX, 5, 1.5)
}

#[bench]
fn serialize_large_sparse_v2(b: &mut Bencher) {
// 6291456 buckets
do_serialize_bench(b, &mut V2Serializer::new(), 1, u64::max_value(), 5, 0.1)
do_serialize_bench(b, &mut V2Serializer::new(), 1, u64::MAX, 5, 0.1)
}

#[bench]
Expand All @@ -68,7 +68,7 @@ fn serialize_large_dense_v2_deflate(b: &mut Bencher) {
b,
&mut V2DeflateSerializer::new(),
1,
u64::max_value(),
u64::MAX,
5,
1.5,
)
Expand All @@ -81,7 +81,7 @@ fn serialize_large_sparse_v2_deflate(b: &mut Bencher) {
b,
&mut V2DeflateSerializer::new(),
1,
u64::max_value(),
u64::MAX,
5,
0.1,
)
Expand Down Expand Up @@ -114,25 +114,25 @@ fn deserialize_small_sparse_v2(b: &mut Bencher) {
#[bench]
fn deserialize_medium_dense_v2(b: &mut Bencher) {
// 56320 counts
do_deserialize_bench(b, &mut V2Serializer::new(), 1, u64::max_value(), 3, 1.5)
do_deserialize_bench(b, &mut V2Serializer::new(), 1, u64::MAX, 3, 1.5)
}

#[bench]
fn deserialize_medium_sparse_v2(b: &mut Bencher) {
// 56320 counts
do_deserialize_bench(b, &mut V2Serializer::new(), 1, u64::max_value(), 3, 0.1)
do_deserialize_bench(b, &mut V2Serializer::new(), 1, u64::MAX, 3, 0.1)
}

#[bench]
fn deserialize_large_dense_v2(b: &mut Bencher) {
// 6291456 buckets
do_deserialize_bench(b, &mut V2Serializer::new(), 1, u64::max_value(), 5, 1.5)
do_deserialize_bench(b, &mut V2Serializer::new(), 1, u64::MAX, 5, 1.5)
}

#[bench]
fn deserialize_large_sparse_v2(b: &mut Bencher) {
// 6291456 buckets
do_deserialize_bench(b, &mut V2Serializer::new(), 1, u64::max_value(), 5, 0.1)
do_deserialize_bench(b, &mut V2Serializer::new(), 1, u64::MAX, 5, 0.1)
}

#[bench]
Expand All @@ -142,7 +142,7 @@ fn deserialize_large_dense_v2_deflate(b: &mut Bencher) {
b,
&mut V2DeflateSerializer::new(),
1,
u64::max_value(),
u64::MAX,
5,
1.5,
)
Expand All @@ -155,7 +155,7 @@ fn deserialize_large_sparse_v2_deflate(b: &mut Bencher) {
b,
&mut V2DeflateSerializer::new(),
1,
u64::max_value(),
u64::MAX,
5,
0.1,
)
Expand Down
4 changes: 2 additions & 2 deletions examples/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use hdrhistogram::serialization::{
use hdrhistogram::{Histogram, RecordError};

fn main() {
let default_max = format!("{}", u64::max_value());
let default_max = format!("{}", u64::MAX);
let matches = Command::new("hdrhistogram cli")
.subcommand(
Command::new("serialize")
Expand Down Expand Up @@ -228,7 +228,7 @@ fn quantiles<R: BufRead, W: Write>(
// Normally I frown on excessive use of From as it's too "magic", but in the limited confines of
// subcommands, the convenience seems worth it.
#[derive(Debug)]
enum CliError {
pub enum CliError {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow why this was made pub?

Io(io::Error),
HistogramSerialize(V2SerializeError),
HistogramSerializeCompressed(V2DeflateSerializeError),
Expand Down
4 changes: 2 additions & 2 deletions src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::fmt;
pub enum CreationError {
/// Lowest discernible value must be >= 1.
LowIsZero,
/// Lowest discernible value must be <= `u64::max_value() / 2` because the highest value is
/// Lowest discernible value must be <= \x60u64::MAX / 2\x60 because the highest value is
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Lowest discernible value must be <= \x60u64::MAX / 2\x60 because the highest value is
/// Lowest discernible value must be <= `u64::MAX / 2` because the highest value is

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've used this \x60 version in a few places now — could you change all of them back to backtick please?

/// a `u64` and the lowest value must be no bigger than half the highest.
LowExceedsMax,
/// Highest trackable value must be >= 2 * lowest discernible value for some internal
Expand Down Expand Up @@ -78,7 +78,7 @@ impl fmt::Display for CreationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
CreationError::LowIsZero => write!(f, "Lowest discernible value must be >= 1"),
CreationError::LowExceedsMax => write!(f, "Lowest discernible value must be <= `u64::max_value() / 2`"),
CreationError::LowExceedsMax => write!(f, "Lowest discernible value must be <= \x60u64::MAX / 2\x60"),
CreationError::HighLessThanTwiceLow => write!(f, "Highest trackable value must be >= 2 * lowest discernible value for some internal calculations"),
CreationError::SigFigExceedsMax => write!(f, "Number of significant digits must be in the range `[0, 5]`"),
CreationError::CannotRepresentSigFigBeyondLow => write!(f, "Cannot represent sigfig worth of values beyond the lowest discernible value"),
Expand Down
Loading