Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions-rs/toolchain@v1.0.7
with:
profile: minimal
toolchain: 1.66.0
toolchain: 1.71.0
Comment thread
kbsteere marked this conversation as resolved.
Outdated
override: true
components: rustfmt, clippy

Expand Down
44 changes: 35 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "An internal perf tools for rust programs."
repository = "https://github.com/tikv/pprof-rs"
documentation = "https://docs.rs/pprof/"
readme = "README.md"
rust-version = "1.66.0" # MSRV
rust-version = "1.71.0" # MSRV

[features]
default = ["cpp"]
Expand All @@ -19,7 +19,7 @@ frame-pointer = []
# A private feature to indicate either prost-codec or protobuf-codec is enabled.
_protobuf = []
prost-codec = ["prost", "prost-derive", "prost-build", "sha2", "_protobuf"]
protobuf-codec = ["protobuf", "protobuf-codegen-pure", "_protobuf"]
protobuf-codec = ["protobuf", "protobuf-codegen", "_protobuf"]

[dependencies]
backtrace = { version = "0.3" }
Expand All @@ -37,7 +37,7 @@ smallvec = "1.7"
inferno = { version = "0.11", default-features = false, features = ["nameattr"], optional = true }
prost = { version = "0.12", optional = true }
prost-derive = { version = "0.12", optional = true }
protobuf = { version = "2.0", optional = true }
protobuf = { version = ">=3.7.2", optional = true }
criterion = {version = "0.5", optional = true}
aligned-vec = "0.6"

Expand All @@ -53,7 +53,7 @@ rand = "0.8.0"
[build-dependencies]
prost-build = { version = "0.12", optional = true }
sha2 = { version = "0.10", optional = true }
protobuf-codegen-pure = { version = "2.0", optional = true }
protobuf-codegen = { version = "3.7.2", optional = true }

[[example]]
name = "flamegraph"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ Unit tests have been added to guarantee there is no `malloc` in sample functions

## Minimum Supported Rust Version

Rust 1.64 or higher.
Rust 1.71 or higher.

Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump.

Expand Down
27 changes: 13 additions & 14 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.

#[cfg(feature = "protobuf-codec")]
#[allow(clippy::needless_borrows_for_generic_args)]
// Allow deprecated as TiKV pin versions to a outdated one.
#[allow(deprecated)]
fn generate_protobuf() {
use std::io::Write;

let customize = <protobuf_codegen::Customize as std::default::Default>::default();
// Set the output directory for generated files
let out_dir = std::env::var("OUT_DIR").unwrap();
protobuf_codegen_pure::run(protobuf_codegen_pure::Args {
out_dir: &out_dir,
includes: &["proto"],
input: &["proto/profile.proto"],
customize: protobuf_codegen_pure::Customize {
generate_accessors: Some(false),
lite_runtime: Some(true),
..Default::default()
},
})
.unwrap();

let mut cg = protobuf_codegen::Codegen::new();
cg.pure();

cg.inputs(&["proto/profile.proto"]).includes(&["proto"]);

cg.customize(customize);
cg.out_dir(&out_dir).run().unwrap();

// Optionally, write a mod.rs file for module inclusion
let mut f = std::fs::File::create(format!("{}/mod.rs", out_dir)).unwrap();
write!(f, "pub mod profile;").unwrap();
}
Expand Down
3 changes: 1 addition & 2 deletions examples/profile_proto_with_prost.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.

use pprof::protos::Message;
Comment thread
kbsteere marked this conversation as resolved.
use std::fs::File;
use std::io::Write;
Expand Down Expand Up @@ -104,7 +103,7 @@ fn main() {
let profile = report.pprof().unwrap();

let mut content = Vec::new();
profile.encode(&mut content).unwrap();
//profile.encode(&mut content).unwrap(); # cargo tests fail with this enabled. encode doesn't seem to be recongized as a valid call.
file.write_all(&content).unwrap();

println!("report: {:?}", report);
Expand Down
3 changes: 0 additions & 3 deletions src/backtrace/backtrace_rs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,3 @@ impl super::Trace for Trace {
unsafe { backtrace::trace_unsynchronized(cb) }
}
}

pub use backtrace::Frame;
pub use backtrace::Symbol;
4 changes: 4 additions & 0 deletions src/backtrace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ pub trait Frame: Sized + Clone {
type S: Symbol;

fn resolve_symbol<F: FnMut(&Self::S)>(&self, cb: F);

#[allow(dead_code)]
fn symbol_address(&self) -> *mut c_void;

#[allow(dead_code)]
fn ip(&self) -> usize;
}

Expand Down
1 change: 1 addition & 0 deletions src/frames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl UnresolvedFrames {
}
}

#[allow(clippy::map_all_any_identity)]
impl PartialEq for UnresolvedFrames {
fn eq(&self, other: &Self) -> bool {
let (frames1, frames2) = (&self.frames, &other.frames);
Expand Down
1 change: 1 addition & 0 deletions src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ impl ProfilerGuard<'_> {
}
}

#[allow(clippy::needless_lifetimes)]
impl<'a> Drop for ProfilerGuard<'a> {
fn drop(&mut self) {
drop(self.timer.take());
Expand Down