Skip to content
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

ignore prost mod and fix clippy warning #160

Merged
merged 1 commit into from Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib.rs
Expand Up @@ -65,6 +65,7 @@ pub use self::report::{Report, ReportBuilder, UnresolvedReport};
#[cfg(feature = "flamegraph")]
pub use inferno::flamegraph;

#[allow(clippy::all)]
Copy link
Member

Choose a reason for hiding this comment

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

Why? What problem it's trying to solve?

Copy link
Member Author

Choose a reason for hiding this comment

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

See https://github.com/tikv/pprof-rs/runs/7899854996?check_suite_focus=true, it ignores the clippy error produced in the codes generated by prost.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it better to be more conservative about suppressing warnings like in tokio-rs/prost#661 (comment)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it better to be more conservative about suppressing warnings like in tokio-rs/prost#661 (comment)?

@sticnarf I don't think so. If more clippy warnings appears in the prost mod, what we can do is still ignoring them. It seems that being more conservative doesn't make it better.

Copy link
Contributor

Choose a reason for hiding this comment

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

The advantage I can think of is when it's a warning about correctness or performance, it's possible to find and report to the prost upstream. Well, of course, we can rely on others using prost to do the same.

I think both are ok.

#[cfg(all(feature = "prost-codec", not(feature = "protobuf-codec")))]
pub mod protos {
pub use prost::Message;
Expand Down
15 changes: 8 additions & 7 deletions src/report.rs
Expand Up @@ -29,9 +29,11 @@ pub struct UnresolvedReport {
pub timing: ReportTiming,
}

type FramesPostProcessor = Box<dyn Fn(&mut Frames)>;

/// A builder of `Report` and `UnresolvedReport`. It builds report from a running `Profiler`.
pub struct ReportBuilder<'a> {
frames_post_processor: Option<Box<dyn Fn(&mut Frames)>>,
frames_post_processor: Option<FramesPostProcessor>,
profiler: &'a RwLock<Result<Profiler>>,
timing: ReportTiming,
}
Expand Down Expand Up @@ -159,13 +161,13 @@ impl Debug for Report {
mod flamegraph {
use super::*;
use inferno::flamegraph;
use std::io::Write;
use std::fmt::Write;

impl Report {
/// `flamegraph` will write an svg flamegraph into `writer` **only available with `flamegraph` feature**
pub fn flamegraph<W>(&self, writer: W) -> Result<()>
where
W: Write,
W: std::io::Write,
{
self.flamegraph_with_options(writer, &mut flamegraph::Options::default())
}
Expand All @@ -177,7 +179,7 @@ mod flamegraph {
options: &mut flamegraph::Options,
) -> Result<()>
where
W: Write,
W: std::io::Write,
{
let lines: Vec<String> = self
.data
Expand All @@ -188,13 +190,12 @@ mod flamegraph {

for frame in key.frames.iter().rev() {
for symbol in frame.iter().rev() {
line.push_str(&format!("{}", symbol));
line.push(';');
write!(&mut line, "{};", symbol).unwrap();
}
}

line.pop().unwrap_or_default();
line.push_str(&format!(" {}", value));
write!(&mut line, " {}", value).unwrap();

line
})
Expand Down