Skip to content

Commit

Permalink
Merge pull request #1355 from mich2000/chore/cargo-fix
Browse files Browse the repository at this point in the history
apply cargo clippy fix
  • Loading branch information
spacejam committed Jul 26, 2021
2 parents 2259a0b + 92c8190 commit 9dacc97
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 62 deletions.
114 changes: 57 additions & 57 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,35 +196,35 @@ impl Metrics {
pub fn format_profile(&self) -> String {
let mut ret = String::new();
ret.push_str(&format!(
"sled profile:\n\
"sled profile:\n\
{0: >17} | {1: >10} | {2: >10} | {3: >10} | {4: >10} | {5: >10} | {6: >10} | {7: >10} | {8: >10} | {9: >10}\n",
"op",
"min (us)",
"med (us)",
"90 (us)",
"99 (us)",
"99.9 (us)",
"99.99 (us)",
"max (us)",
"count",
"sum (s)"
));
"op",
"min (us)",
"med (us)",
"90 (us)",
"99 (us)",
"99.9 (us)",
"99.99 (us)",
"max (us)",
"count",
"sum (s)"
));
ret.push_str(&format!(
"{}\n",
std::iter::repeat("-").take(134).collect::<String>()
));
"{}\n",
"-".repeat(134)
));

let p =
|mut tuples: Vec<(String, _, _, _, _, _, _, _, _, _)>| -> String {
tuples.sort_by_key(|t| (t.9 * -1. * 1e3) as i64);
let mut ret = String::new();
for v in tuples {
ret.push_str(&format!(
"{0: >17} | {1: >10.1} | {2: >10.1} | {3: >10.1} \
"{0: >17} | {1: >10.1} | {2: >10.1} | {3: >10.1} \
| {4: >10.1} | {5: >10.1} | {6: >10.1} | {7: >10.1} \
| {8: >10.1} | {9: >10.1}\n",
v.0, v.1, v.2, v.3, v.4, v.5, v.6, v.7, v.8, v.9,
));
v.0, v.1, v.2, v.3, v.4, v.5, v.6, v.7, v.8, v.9,
));
}
ret
};
Expand All @@ -241,7 +241,7 @@ impl Metrics {
histo.percentile(100.) / 1e3,
histo.count(),
histo.sum() as f64 / 1e9,
)
)
};

let sz = |name: &str, histo: &Histogram| {
Expand All @@ -256,20 +256,20 @@ impl Metrics {
histo.percentile(100.),
histo.count(),
histo.sum() as f64,
)
)
};

ret.push_str("tree:\n");

ret.push_str(&p(vec![
lat("traverse", &self.tree_traverse),
lat("get", &self.tree_get),
lat("set", &self.tree_set),
lat("merge", &self.tree_merge),
lat("del", &self.tree_del),
lat("cas", &self.tree_cas),
lat("scan", &self.tree_scan),
lat("rev scan", &self.tree_reverse_scan),
lat("traverse", &self.tree_traverse),
lat("get", &self.tree_get),
lat("set", &self.tree_set),
lat("merge", &self.tree_merge),
lat("del", &self.tree_del),
lat("cas", &self.tree_cas),
lat("scan", &self.tree_scan),
lat("rev scan", &self.tree_reverse_scan),
]));
let total_loops = self.tree_loops.load(Acquire);
let total_ops = self.tree_get.count()
Expand All @@ -281,34 +281,34 @@ impl Metrics {
+ self.tree_reverse_scan.count();
let loop_pct = total_loops * 100 / (total_ops + 1);
ret.push_str(&format!(
"tree contention loops: {} ({}% retry rate)\n",
total_loops, loop_pct
));
"tree contention loops: {} ({}% retry rate)\n",
total_loops, loop_pct
));
ret.push_str(&format!(
"tree split success rates: child({}/{}) parent({}/{}) root({}/{})\n",
self.tree_child_split_success.load(Acquire)
.to_formatted_string(&Locale::en)
,
self.tree_child_split_attempt.load(Acquire)
.to_formatted_string(&Locale::en)
,
self.tree_parent_split_success.load(Acquire)
.to_formatted_string(&Locale::en)
,
self.tree_parent_split_attempt.load(Acquire)
.to_formatted_string(&Locale::en)
,
self.tree_root_split_success.load(Acquire)
.to_formatted_string(&Locale::en)
,
self.tree_root_split_attempt.load(Acquire)
.to_formatted_string(&Locale::en)
,
));
"tree split success rates: child({}/{}) parent({}/{}) root({}/{})\n",
self.tree_child_split_success.load(Acquire)
.to_formatted_string(&Locale::en)
,
self.tree_child_split_attempt.load(Acquire)
.to_formatted_string(&Locale::en)
,
self.tree_parent_split_success.load(Acquire)
.to_formatted_string(&Locale::en)
,
self.tree_parent_split_attempt.load(Acquire)
.to_formatted_string(&Locale::en)
,
self.tree_root_split_success.load(Acquire)
.to_formatted_string(&Locale::en)
,
self.tree_root_split_attempt.load(Acquire)
.to_formatted_string(&Locale::en)
,
));

ret.push_str(&format!(
"{}\n",
std::iter::repeat("-").take(134).collect::<String>()
"{}\n",
"-".repeat(134)
));
ret.push_str("pagecache:\n");
ret.push_str(&p(vec![
Expand All @@ -327,7 +327,7 @@ impl Metrics {

ret.push_str(&format!(
"{}\n",
std::iter::repeat("-").take(134).collect::<String>()
"-".repeat(134)
));
ret.push_str("serialization and compression:\n");
ret.push_str(&p(vec![
Expand All @@ -341,7 +341,7 @@ impl Metrics {

ret.push_str(&format!(
"{}\n",
std::iter::repeat("-").take(134).collect::<String>()
"-".repeat(134)
));
ret.push_str("log:\n");
ret.push_str(&p(vec![
Expand Down Expand Up @@ -403,7 +403,7 @@ impl Metrics {

ret.push_str(&format!(
"{}\n",
std::iter::repeat("-").take(134).collect::<String>()
"-".repeat(134)
));
ret.push_str("segment accountant:\n");
ret.push_str(&p(vec![
Expand All @@ -417,7 +417,7 @@ impl Metrics {

ret.push_str(&format!(
"{}\n",
std::iter::repeat("-").take(134).collect::<String>()
"-".repeat(134)
));
ret.push_str("recovery:\n");
ret.push_str(&p(vec![
Expand Down
8 changes: 3 additions & 5 deletions src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,10 @@ fn shift_i64_opt(value_opt: &Option<i64>) -> i64 {

const fn unshift_i64_opt(value: i64) -> Option<i64> {
if value == 0 {
None
} else if value < 0 {
Some(value)
} else {
Some(value - 1)
return None
}
let subtract = value > 0;
Some(value - subtract as i64)
}

impl Serialize for Snapshot {
Expand Down

0 comments on commit 9dacc97

Please sign in to comment.