From b156a0524bf1c6cfc4cf1bc9051928817a776bcd Mon Sep 17 00:00:00 2001 From: Breezewish Date: Mon, 24 Dec 2018 16:45:32 +0800 Subject: [PATCH 1/9] Support profiling sections of code Signed-off-by: Breezewish --- Cargo.lock | 27 +++++++++++++++++ Cargo.toml | 6 ++-- components/cpu_profiler/Cargo.toml | 7 +++++ components/cpu_profiler/src/lib.rs | 27 +++++++++++++++++ components/cpu_profiler/src/profiler_dummy.rs | 27 +++++++++++++++++ components/cpu_profiler/src/profiler_linux.rs | 29 +++++++++++++++++++ 6 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 components/cpu_profiler/Cargo.toml create mode 100644 components/cpu_profiler/src/lib.rs create mode 100644 components/cpu_profiler/src/profiler_dummy.rs create mode 100644 components/cpu_profiler/src/profiler_linux.rs diff --git a/Cargo.lock b/Cargo.lock index edc8e02137d..bc8029672ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -284,6 +284,22 @@ dependencies = [ "tipb 0.0.1 (git+https://github.com/pingcap/tipb.git)", ] +[[package]] +name = "cpu_profiler" +version = "0.0.1" +dependencies = [ + "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cpuprofiler" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "error-chain 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crc" version = "1.8.1" @@ -480,6 +496,14 @@ dependencies = [ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "error-chain" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "error-chain" version = "0.12.0" @@ -1979,6 +2003,7 @@ dependencies = [ "chrono-tz 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "cop_datatype 0.0.1", + "cpu_profiler 0.0.1", "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2474,6 +2499,7 @@ dependencies = [ "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmake 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "6ec65ee4f9c9d16f335091d23693457ed4928657ba4982289d7fafee03bc614a" "checksum cookie 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0e3d6405328b6edb412158b3b7710e2634e23f3614b9bb1c412df7952489a626" +"checksum cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "33f07976bb6821459632d7a18d97ccca005cb5c552f251f822c7c1781c1d7035" "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum criterion 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b027da737a814e7ffcfdbaf1c0509fbaea4c6df5f2e116c820ecf515ad39ac9b" "checksum criterion-plot 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7894b77aa2820337ddf3a6655c24116fb7e53dbdc9735d43a4dec7da5d2c4716" @@ -2494,6 +2520,7 @@ dependencies = [ "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" "checksum enum-primitive-derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b90e520ec62c1864c8c78d637acbfe8baf5f63240f2fb8165b8325c07812dd" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" +"checksum error-chain 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd5c82c815138e278b8dcdeffc49f27ea6ffb528403e9dea4194f2e3dd40b143" "checksum fail 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd2e1a22c616c8c8c96b6e07c243014551f3ba77291d24c22e0bfea6830c0b4e" "checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" "checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" diff --git a/Cargo.toml b/Cargo.toml index 4b84a0b9f34..1e22f183bfa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ portable = ["rocksdb/portable"] sse = ["rocksdb/sse"] mem-profiling = ["jemallocator/profiling"] no-fail = ["fail/no_fail"] +cpu-profiling = [] [lib] name = "tikv" @@ -101,15 +102,16 @@ num = "0.2" num-traits = "0.2" hex = "0.3" rust-crypto = "^0.2" -panic_hook = { path = "components/panic_hook" } base64 = "0.10" safemem = "0.3" -cop_datatype = { path = "components/cop_datatype" } smallvec = { version = "0.6", features = ["union"] } flate2 = { version = "1.0", features = ["zlib"], default-features = false } more-asserts = "0.1" hyper = "0.12" tokio-threadpool = "0.1" +cop_datatype = { path = "components/cop_datatype" } +panic_hook = { path = "components/panic_hook" } +cpu_profiler = { path = "components/cpu_profiler" } [dependencies.murmur3] git = "https://github.com/pingcap/murmur3.git" diff --git a/components/cpu_profiler/Cargo.toml b/components/cpu_profiler/Cargo.toml new file mode 100644 index 00000000000..ca5846c0115 --- /dev/null +++ b/components/cpu_profiler/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "cpu_profiler" +version = "0.0.1" +publish = false + +[target.'cfg(target_os = "linux")'.dependencies] +cpuprofiler = "0.0.3" diff --git a/components/cpu_profiler/src/lib.rs b/components/cpu_profiler/src/lib.rs new file mode 100644 index 00000000000..580a2a9e504 --- /dev/null +++ b/components/cpu_profiler/src/lib.rs @@ -0,0 +1,27 @@ +// Copyright 2018 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +#[cfg(target_os = "linux")] +extern crate cpuprofiler; + +#[cfg(all(target_os = "linux", feature = "cpu-profiling"))] +mod profiler_linux; + +#[cfg(all(target_os = "linux", feature = "cpu-profiling"))] +pub use profiler_linux::*; + +#[cfg(not(all(target_os = "linux", feature = "cpu-profiling")))] +mod profiler_dummy; + +#[cfg(not(all(target_os = "linux", feature = "cpu-profiling")))] +pub use profiler_dummy::*; diff --git a/components/cpu_profiler/src/profiler_dummy.rs b/components/cpu_profiler/src/profiler_dummy.rs new file mode 100644 index 00000000000..2ee2ed4db58 --- /dev/null +++ b/components/cpu_profiler/src/profiler_dummy.rs @@ -0,0 +1,27 @@ +// Copyright 2018 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +#[inline] +pub fn start(_fname: impl Into>) { + // Do nothing +} + +#[inline] +pub fn stop() { + // Do nothing +} + +#[inline] +pub fn is_enabled() -> bool { + false +} diff --git a/components/cpu_profiler/src/profiler_linux.rs b/components/cpu_profiler/src/profiler_linux.rs new file mode 100644 index 00000000000..8c961ef0d19 --- /dev/null +++ b/components/cpu_profiler/src/profiler_linux.rs @@ -0,0 +1,29 @@ +// Copyright 2018 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +use cpuprofiler::PROFILER; + +#[inline] +pub fn start(fname: impl Into>) { + PROFILER.lock().unwrap().start(fname).unwrap(); +} + +#[inline] +pub fn stop() { + PROFILER.lock().unwrap().stop().unwrap(); +} + +#[inline] +pub fn is_enabled() -> bool { + true +} From 9ddf5e91a7d8ee1a7857c86ac828afb00716d931 Mon Sep 17 00:00:00 2001 From: Breezewish Date: Tue, 25 Dec 2018 00:06:12 +0800 Subject: [PATCH 2/9] Support Callgrind Signed-off-by: Breezewish --- Cargo.lock | 35 ++++-- Cargo.toml | 4 +- components/cpu_profiler/Cargo.toml | 7 -- components/cpu_profiler/src/lib.rs | 27 ----- components/cpu_profiler/src/profiler_linux.rs | 29 ----- components/profiler/Cargo.toml | 13 +++ components/profiler/examples/prime.rs | 101 ++++++++++++++++++ components/profiler/src/lib.rs | 79 ++++++++++++++ .../src/profiler_dummy.rs | 7 +- components/profiler/src/profiler_linux.rs | 89 +++++++++++++++ 10 files changed, 312 insertions(+), 79 deletions(-) delete mode 100644 components/cpu_profiler/Cargo.toml delete mode 100644 components/cpu_profiler/src/lib.rs delete mode 100644 components/cpu_profiler/src/profiler_linux.rs create mode 100644 components/profiler/Cargo.toml create mode 100644 components/profiler/examples/prime.rs create mode 100644 components/profiler/src/lib.rs rename components/{cpu_profiler => profiler}/src/profiler_dummy.rs (86%) create mode 100644 components/profiler/src/profiler_linux.rs diff --git a/Cargo.lock b/Cargo.lock index bc8029672ec..40b4fe32ee5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -176,6 +176,15 @@ dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "callgrind" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "valgrind_request 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cargo_metadata" version = "0.6.3" @@ -284,13 +293,6 @@ dependencies = [ "tipb 0.0.1 (git+https://github.com/pingcap/tipb.git)", ] -[[package]] -name = "cpu_profiler" -version = "0.0.1" -dependencies = [ - "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "cpuprofiler" version = "0.0.3" @@ -1364,6 +1366,16 @@ dependencies = [ "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "profiler" +version = "0.0.1" +dependencies = [ + "callgrind 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "valgrind_request 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "prometheus" version = "0.4.2" @@ -2003,7 +2015,6 @@ dependencies = [ "chrono-tz 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "cop_datatype 0.0.1", - "cpu_profiler 0.0.1", "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2031,6 +2042,7 @@ dependencies = [ "num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "panic_hook 0.0.1", + "profiler 0.0.1", "prometheus 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "prometheus-static-metric 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2373,6 +2385,11 @@ dependencies = [ "serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "valgrind_request" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "vcpkg" version = "0.2.2" @@ -2489,6 +2506,7 @@ dependencies = [ "checksum bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c129aff112dcc562970abb69e2508b40850dd24c274761bb50fb8a0067ba6c27" "checksum bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "40ade3d27603c2cb345eb0912aec461a6dec7e06a4ae48589904e808335c7afa" "checksum bzip2-sys 0.1.7 (git+https://github.com/alexcrichton/bzip2-rs.git)" = "" +"checksum callgrind 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f7f788eaf239475a3c1e1acf89951255a46c4b9b46cf3e866fc4d0707b4b9e36" "checksum cargo_metadata 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "48e8d5fd5b81d86d3ec3c820ecf5a3027fa22d6aede2be981cf07a8ce16451bb" "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" @@ -2714,6 +2732,7 @@ dependencies = [ "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum utime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4a9c0ddf7a5a39cd0c316dac124303d71fa197f8607027546c3be3e1c6f7bd9b" "checksum uuid 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8630752f979f1b6b87c49830a5e3784082545de63920d59fbaac252474319447" +"checksum valgrind_request 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0fb139b14473e1350e34439c888e44c805f37b4293d17f87ea920a66a20a99a" "checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" diff --git a/Cargo.toml b/Cargo.toml index 1e22f183bfa..bc53047b647 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ portable = ["rocksdb/portable"] sse = ["rocksdb/sse"] mem-profiling = ["jemallocator/profiling"] no-fail = ["fail/no_fail"] -cpu-profiling = [] +profiling = ["profiler/profiling"] [lib] name = "tikv" @@ -111,7 +111,7 @@ hyper = "0.12" tokio-threadpool = "0.1" cop_datatype = { path = "components/cop_datatype" } panic_hook = { path = "components/panic_hook" } -cpu_profiler = { path = "components/cpu_profiler" } +profiler = { path = "components/profiler" } [dependencies.murmur3] git = "https://github.com/pingcap/murmur3.git" diff --git a/components/cpu_profiler/Cargo.toml b/components/cpu_profiler/Cargo.toml deleted file mode 100644 index ca5846c0115..00000000000 --- a/components/cpu_profiler/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "cpu_profiler" -version = "0.0.1" -publish = false - -[target.'cfg(target_os = "linux")'.dependencies] -cpuprofiler = "0.0.3" diff --git a/components/cpu_profiler/src/lib.rs b/components/cpu_profiler/src/lib.rs deleted file mode 100644 index 580a2a9e504..00000000000 --- a/components/cpu_profiler/src/lib.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 PingCAP, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// See the License for the specific language governing permissions and -// limitations under the License. - -#[cfg(target_os = "linux")] -extern crate cpuprofiler; - -#[cfg(all(target_os = "linux", feature = "cpu-profiling"))] -mod profiler_linux; - -#[cfg(all(target_os = "linux", feature = "cpu-profiling"))] -pub use profiler_linux::*; - -#[cfg(not(all(target_os = "linux", feature = "cpu-profiling")))] -mod profiler_dummy; - -#[cfg(not(all(target_os = "linux", feature = "cpu-profiling")))] -pub use profiler_dummy::*; diff --git a/components/cpu_profiler/src/profiler_linux.rs b/components/cpu_profiler/src/profiler_linux.rs deleted file mode 100644 index 8c961ef0d19..00000000000 --- a/components/cpu_profiler/src/profiler_linux.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 PingCAP, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// See the License for the specific language governing permissions and -// limitations under the License. - -use cpuprofiler::PROFILER; - -#[inline] -pub fn start(fname: impl Into>) { - PROFILER.lock().unwrap().start(fname).unwrap(); -} - -#[inline] -pub fn stop() { - PROFILER.lock().unwrap().stop().unwrap(); -} - -#[inline] -pub fn is_enabled() -> bool { - true -} diff --git a/components/profiler/Cargo.toml b/components/profiler/Cargo.toml new file mode 100644 index 00000000000..b520c4beb84 --- /dev/null +++ b/components/profiler/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "profiler" +version = "0.0.1" +publish = false + +[features] +profiling = [] + +[dependencies] +lazy_static = "1.2.0" +cpuprofiler = "0.0.3" +callgrind = "1.1.0" +valgrind_request = "1.1.0" diff --git a/components/profiler/examples/prime.rs b/components/profiler/examples/prime.rs new file mode 100644 index 00000000000..4b1b8cad069 --- /dev/null +++ b/components/profiler/examples/prime.rs @@ -0,0 +1,101 @@ +// Copyright 2018 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Profiling sample: Calculate prime numbers. +//! +//! ## Usage +//! +//! ### Build +//! +//! ```bash +//! cargo build --features "profiling" --example prime +//! ``` +//! +//! (You may also want `--release` in real scenarios). +//! +//! ### Run using CPU Profiler +//! +//! ```bash +//! TIKV_PROFILE=1 ../../target/debug/examples/prime +//! ``` +//! +//! ### Run using Callgrind +//! +//! ```bash +//! TIKV_PROFILE=1 valgrind --tool=callgrind --instr-atstart=no ../../target/debug/examples/prime +//! ``` +//! +//! You must not run example via `valgrind cargo run ...`. The framework won't detect Callgrind! + +extern crate profiler; + +#[inline(never)] +fn is_prime_number(v: usize, prime_numbers: &[usize]) -> bool { + if v < 10000 { + let r = prime_numbers.binary_search(&v); + if let Ok(_) = r { + return true; + } else { + return false; + } + } + + for n in prime_numbers { + if v % n == 0 { + return false; + } + } + + return true; +} + +#[inline(never)] +fn prepare_prime_numbers() -> Vec { + // bootstrap: Generate a prime table of 0..10000 + let mut prime_number_table: [bool; 10000] = [true; 10000]; + prime_number_table[0] = false; + prime_number_table[1] = false; + for i in 2..10000 { + if prime_number_table[i] { + let mut v = i * 2; + while v < 10000 { + prime_number_table[v] = false; + v += i; + } + } + } + let mut prime_numbers = vec![]; + for i in 2..10000 { + if prime_number_table[i] { + prime_numbers.push(i); + } + } + prime_numbers +} + +fn main() { + let prime_numbers = prepare_prime_numbers(); + + profiler::start("prime.profile"); + + let mut v = 0; + for i in 2..50000 { + if is_prime_number(i, &prime_numbers) { + v += 1; + } + } + + profiler::stop(); + + println!("Prime numbers: {}", v); +} diff --git a/components/profiler/src/lib.rs b/components/profiler/src/lib.rs new file mode 100644 index 00000000000..7e332241568 --- /dev/null +++ b/components/profiler/src/lib.rs @@ -0,0 +1,79 @@ +// Copyright 2018 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Profile a part of the code using CPU Profiler from gperftools or Callgrind. +//! +//! ## Requirements +//! +//! 1. Linux +//! +//! Other OS may also work however, not tested. +//! +//! 2. gperftools +//! +//! You can follow its [INSTALL manual](https://github.com/gperftools/gperftools/blob/master/INSTALL). +//! Roughly the instructions are the following: +//! +//! 1. Download packages from [release](https://github.com/gperftools/gperftools/releases) +//! 2. Run `./configure` +//! 3. Run `make install` +//! +//! ## Usage +//! +//! ```rust +//! profiler::start("./app.profile"); +//! some_complex_code(); +//! profiler::stop(); +//! ``` +//! +//! Then, compile the code with `profiling` feature enabled and run the code with environment +//! variable `TIKV_PROFILE=1`. +//! +//! By default, a profile called `app.profile` will be generated by CPU Profiler. +//! You can then analyze the profile using [pprof](https://github.com/google/pprof). +//! +//! If the application is running in Callgrind, a Callgrind profile dump will be generated instead. +//! Notice that you should run Callgrind with command line option `--instr-atstart=no`, e.g.: +//! +//! ```bash +//! TIKV_PROFILE=1 valgrind --tool=callgrind --instr-atstart=no ./my_example +//! ``` +//! +//! Also see `examples/prime.rs`. + +// TODO: Simplify these using Edition 2018. + +#[cfg(all(target_os = "linux", feature = "profiling"))] +#[macro_use] +extern crate lazy_static; + +#[cfg(all(target_os = "linux", feature = "profiling"))] +extern crate cpuprofiler; + +#[cfg(all(target_os = "linux", feature = "profiling"))] +extern crate valgrind_request; + +#[cfg(all(target_os = "linux", feature = "profiling"))] +extern crate callgrind; + +#[cfg(all(target_os = "linux", feature = "profiling"))] +mod profiler_linux; + +#[cfg(all(target_os = "linux", feature = "profiling"))] +pub use profiler_linux::*; + +#[cfg(not(all(target_os = "linux", feature = "profiling")))] +mod profiler_dummy; + +#[cfg(not(all(target_os = "linux", feature = "profiling")))] +pub use profiler_dummy::*; diff --git a/components/cpu_profiler/src/profiler_dummy.rs b/components/profiler/src/profiler_dummy.rs similarity index 86% rename from components/cpu_profiler/src/profiler_dummy.rs rename to components/profiler/src/profiler_dummy.rs index 2ee2ed4db58..fff6729d250 100644 --- a/components/cpu_profiler/src/profiler_dummy.rs +++ b/components/profiler/src/profiler_dummy.rs @@ -12,7 +12,7 @@ // limitations under the License. #[inline] -pub fn start(_fname: impl Into>) { +pub fn start(_name: impl AsRef) { // Do nothing } @@ -20,8 +20,3 @@ pub fn start(_fname: impl Into>) { pub fn stop() { // Do nothing } - -#[inline] -pub fn is_enabled() -> bool { - false -} diff --git a/components/profiler/src/profiler_linux.rs b/components/profiler/src/profiler_linux.rs new file mode 100644 index 00000000000..55b0d140443 --- /dev/null +++ b/components/profiler/src/profiler_linux.rs @@ -0,0 +1,89 @@ +// Copyright 2018 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +use callgrind::CallgrindClientRequest; +use cpuprofiler; +use valgrind_request; + +use std::sync::Mutex; +use std::env; + +#[derive(Debug, PartialEq)] +enum Profiler { + None, + GPerfTools, + CallGrind, +} + +lazy_static! { + #[derive(Debug)] + static ref ACTIVE_PROFILER: Mutex = Mutex::new(Profiler::None); +} + +/// Start profiling when there is environment variable `TIKV_PROFILE=1`. +/// +/// When `profiling` feature is not enabled, this function will do nothing and there is totally +/// zero cost. +/// +/// When running in Callgrind, Callgrind instrumentation will be started +/// (`CALLGRIND_START_INSTRUMENTATION`). Otherwise, the CPU Profiler will be started and profile +/// will be generated to the file specified by `name`. +#[inline] +pub fn start(name: impl AsRef) { + let mut profiler = ACTIVE_PROFILER.lock().unwrap(); + + // Profiling in progress. + if *profiler != Profiler::None { + return; + } + + let activate_profiling = { + let var = env::var("TIKV_PROFILE").ok(); + match var { + None => false, + Some(s) => s == "1" + } + }; + + if !activate_profiling { + *profiler = Profiler::None; + } else { + if valgrind_request::running_on_valgrind() != 0 { + *profiler = Profiler::CallGrind; + CallgrindClientRequest::start(); + } else { + *profiler = Profiler::GPerfTools; + cpuprofiler::PROFILER.lock().unwrap().start(name.as_ref()).unwrap(); + } + } +} + +/// Stop profiling if it is started previously. +/// +/// When `profiling` feature is not enabled, this function will do nothing and there is totally +/// zero cost. +#[inline] +pub fn stop() { + let mut profiler = ACTIVE_PROFILER.lock().unwrap(); + match *profiler { + Profiler::None => {}, + Profiler::CallGrind => { + CallgrindClientRequest::stop(None); + *profiler = Profiler::None; + }, + Profiler::GPerfTools => { + cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); + *profiler = Profiler::None; + } + } +} From 2091edaab3ec75875714fb0e5dbd6b770f7b9b94 Mon Sep 17 00:00:00 2001 From: Breezewish Date: Tue, 25 Dec 2018 00:17:22 +0800 Subject: [PATCH 3/9] Make rustfmt and clippy happy Signed-off-by: Breezewish --- Makefile | 2 +- components/profiler/examples/prime.rs | 8 ++------ components/profiler/src/profiler_linux.rs | 14 +++++++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 8fc67e9e5ea..8f353f5014b 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ clippy: pre-clippy -A implicit_hasher -A large_enum_variant -A new_without_default \ -A new_without_default_derive -A neg_cmp_op_on_partial_ord \ -A too_many_arguments -A excessive_precision -A collapsible_if \ - -A blacklisted_name + -A blacklisted_name -A needless_range_loop dev: format clippy @env FAIL_POINT=1 make test diff --git a/components/profiler/examples/prime.rs b/components/profiler/examples/prime.rs index 4b1b8cad069..f3a22aab28a 100644 --- a/components/profiler/examples/prime.rs +++ b/components/profiler/examples/prime.rs @@ -43,11 +43,7 @@ extern crate profiler; fn is_prime_number(v: usize, prime_numbers: &[usize]) -> bool { if v < 10000 { let r = prime_numbers.binary_search(&v); - if let Ok(_) = r { - return true; - } else { - return false; - } + return r.is_ok(); } for n in prime_numbers { @@ -56,7 +52,7 @@ fn is_prime_number(v: usize, prime_numbers: &[usize]) -> bool { } } - return true; + true } #[inline(never)] diff --git a/components/profiler/src/profiler_linux.rs b/components/profiler/src/profiler_linux.rs index 55b0d140443..154c8d77340 100644 --- a/components/profiler/src/profiler_linux.rs +++ b/components/profiler/src/profiler_linux.rs @@ -15,8 +15,8 @@ use callgrind::CallgrindClientRequest; use cpuprofiler; use valgrind_request; -use std::sync::Mutex; use std::env; +use std::sync::Mutex; #[derive(Debug, PartialEq)] enum Profiler { @@ -51,7 +51,7 @@ pub fn start(name: impl AsRef) { let var = env::var("TIKV_PROFILE").ok(); match var { None => false, - Some(s) => s == "1" + Some(s) => s == "1", } }; @@ -63,7 +63,11 @@ pub fn start(name: impl AsRef) { CallgrindClientRequest::start(); } else { *profiler = Profiler::GPerfTools; - cpuprofiler::PROFILER.lock().unwrap().start(name.as_ref()).unwrap(); + cpuprofiler::PROFILER + .lock() + .unwrap() + .start(name.as_ref()) + .unwrap(); } } } @@ -76,11 +80,11 @@ pub fn start(name: impl AsRef) { pub fn stop() { let mut profiler = ACTIVE_PROFILER.lock().unwrap(); match *profiler { - Profiler::None => {}, + Profiler::None => {} Profiler::CallGrind => { CallgrindClientRequest::stop(None); *profiler = Profiler::None; - }, + } Profiler::GPerfTools => { cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); *profiler = Profiler::None; From 35eb12c7dc9cafa46eda887e0267c8f2bae72f1d Mon Sep 17 00:00:00 2001 From: Breezewish Date: Tue, 25 Dec 2018 10:32:53 +0800 Subject: [PATCH 4/9] Fix doc test Signed-off-by: Breezewish --- components/profiler/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/profiler/src/lib.rs b/components/profiler/src/lib.rs index 7e332241568..d496bcdd861 100644 --- a/components/profiler/src/lib.rs +++ b/components/profiler/src/lib.rs @@ -30,7 +30,7 @@ //! //! ## Usage //! -//! ```rust +//! ```ignore //! profiler::start("./app.profile"); //! some_complex_code(); //! profiler::stop(); From 213229e83a009a59cbb098b1424ea75232f47702 Mon Sep 17 00:00:00 2001 From: Breezewish Date: Wed, 2 Jan 2019 21:31:34 +0800 Subject: [PATCH 5/9] start profiling without env variables Signed-off-by: Breezewish --- components/profiler/examples/prime.rs | 4 +-- components/profiler/src/lib.rs | 5 ++-- components/profiler/src/profiler_linux.rs | 33 ++++++++--------------- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/components/profiler/examples/prime.rs b/components/profiler/examples/prime.rs index f3a22aab28a..96043ba0c30 100644 --- a/components/profiler/examples/prime.rs +++ b/components/profiler/examples/prime.rs @@ -26,13 +26,13 @@ //! ### Run using CPU Profiler //! //! ```bash -//! TIKV_PROFILE=1 ../../target/debug/examples/prime +//! ../../target/debug/examples/prime //! ``` //! //! ### Run using Callgrind //! //! ```bash -//! TIKV_PROFILE=1 valgrind --tool=callgrind --instr-atstart=no ../../target/debug/examples/prime +//! valgrind --tool=callgrind --instr-atstart=no ../../target/debug/examples/prime //! ``` //! //! You must not run example via `valgrind cargo run ...`. The framework won't detect Callgrind! diff --git a/components/profiler/src/lib.rs b/components/profiler/src/lib.rs index d496bcdd861..7ac375f4142 100644 --- a/components/profiler/src/lib.rs +++ b/components/profiler/src/lib.rs @@ -36,8 +36,7 @@ //! profiler::stop(); //! ``` //! -//! Then, compile the code with `profiling` feature enabled and run the code with environment -//! variable `TIKV_PROFILE=1`. +//! Then, compile the code with `profiling` feature enabled. //! //! By default, a profile called `app.profile` will be generated by CPU Profiler. //! You can then analyze the profile using [pprof](https://github.com/google/pprof). @@ -46,7 +45,7 @@ //! Notice that you should run Callgrind with command line option `--instr-atstart=no`, e.g.: //! //! ```bash -//! TIKV_PROFILE=1 valgrind --tool=callgrind --instr-atstart=no ./my_example +//! valgrind --tool=callgrind --instr-atstart=no ./my_example //! ``` //! //! Also see `examples/prime.rs`. diff --git a/components/profiler/src/profiler_linux.rs b/components/profiler/src/profiler_linux.rs index 154c8d77340..cab8b05864b 100644 --- a/components/profiler/src/profiler_linux.rs +++ b/components/profiler/src/profiler_linux.rs @@ -30,7 +30,7 @@ lazy_static! { static ref ACTIVE_PROFILER: Mutex = Mutex::new(Profiler::None); } -/// Start profiling when there is environment variable `TIKV_PROFILE=1`. +/// Start profiling. /// /// When `profiling` feature is not enabled, this function will do nothing and there is totally /// zero cost. @@ -38,6 +38,7 @@ lazy_static! { /// When running in Callgrind, Callgrind instrumentation will be started /// (`CALLGRIND_START_INSTRUMENTATION`). Otherwise, the CPU Profiler will be started and profile /// will be generated to the file specified by `name`. +// TODO: Better multi-thread support. #[inline] pub fn start(name: impl AsRef) { let mut profiler = ACTIVE_PROFILER.lock().unwrap(); @@ -47,28 +48,16 @@ pub fn start(name: impl AsRef) { return; } - let activate_profiling = { - let var = env::var("TIKV_PROFILE").ok(); - match var { - None => false, - Some(s) => s == "1", - } - }; - - if !activate_profiling { - *profiler = Profiler::None; + if valgrind_request::running_on_valgrind() != 0 { + *profiler = Profiler::CallGrind; + CallgrindClientRequest::start(); } else { - if valgrind_request::running_on_valgrind() != 0 { - *profiler = Profiler::CallGrind; - CallgrindClientRequest::start(); - } else { - *profiler = Profiler::GPerfTools; - cpuprofiler::PROFILER - .lock() - .unwrap() - .start(name.as_ref()) - .unwrap(); - } + *profiler = Profiler::GPerfTools; + cpuprofiler::PROFILER + .lock() + .unwrap() + .start(name.as_ref()) + .unwrap(); } } From 05f25ac4b5b9fbd46b4165a091d0454275d0caac Mon Sep 17 00:00:00 2001 From: Breezewish Date: Wed, 2 Jan 2019 21:41:14 +0800 Subject: [PATCH 6/9] Fix lock Signed-off-by: Breezewish --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 42f9e85b02b..ee213055002 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -181,7 +181,7 @@ name = "callgrind" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "valgrind_request 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] From e59f569d7349130c200cdb580c9e17199c7a0520 Mon Sep 17 00:00:00 2001 From: Breezewish Date: Fri, 12 Apr 2019 17:30:06 +0800 Subject: [PATCH 7/9] Use tikv_alloc Signed-off-by: Breezewish --- Cargo.lock | 1 + components/profiler/Cargo.toml | 3 +++ components/profiler/src/lib.rs | 3 +++ 3 files changed, 7 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 8ebc2b0d2c6..d69cb57cf76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1350,6 +1350,7 @@ dependencies = [ "callgrind 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tikv_alloc 0.1.0", "valgrind_request 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/components/profiler/Cargo.toml b/components/profiler/Cargo.toml index 8b22524f77f..3f472f95a2d 100644 --- a/components/profiler/Cargo.toml +++ b/components/profiler/Cargo.toml @@ -7,6 +7,9 @@ publish = false [features] profiling = ["lazy_static", "cpuprofiler", "callgrind", "valgrind_request"] +[dependencies] +tikv_alloc = { path = "../tikv_alloc" } + [target.'cfg(unix)'.dependencies] lazy_static = { version = "1.2.0", optional = true } cpuprofiler = { version = "0.0.3", optional = true } diff --git a/components/profiler/src/lib.rs b/components/profiler/src/lib.rs index 186c241cff4..b0f46ada188 100644 --- a/components/profiler/src/lib.rs +++ b/components/profiler/src/lib.rs @@ -42,6 +42,9 @@ //! //! Also see `examples/prime.rs`. +#[allow(unused_extern_crates)] +extern crate tikv_alloc; + #[cfg(all(unix, feature = "profiling"))] mod profiler_linux; From 5bc7552de6ca07238e4418d4d204b8c426e7225e Mon Sep 17 00:00:00 2001 From: Breezewish Date: Mon, 29 Apr 2019 00:33:00 +0800 Subject: [PATCH 8/9] Address comments about the returning value Signed-off-by: Breezewish --- components/profiler/src/lib.rs | 4 ++-- components/profiler/src/profiler_dummy.rs | 8 ++++++-- .../src/{profiler_linux.rs => profiler_unix.rs} | 16 ++++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) rename components/profiler/src/{profiler_linux.rs => profiler_unix.rs} (82%) diff --git a/components/profiler/src/lib.rs b/components/profiler/src/lib.rs index b0f46ada188..cd54fe45575 100644 --- a/components/profiler/src/lib.rs +++ b/components/profiler/src/lib.rs @@ -46,10 +46,10 @@ extern crate tikv_alloc; #[cfg(all(unix, feature = "profiling"))] -mod profiler_linux; +mod profiler_unix; #[cfg(all(unix, feature = "profiling"))] -pub use profiler_linux::*; +pub use profiler_unix::*; #[cfg(not(all(unix, feature = "profiling")))] mod profiler_dummy; diff --git a/components/profiler/src/profiler_dummy.rs b/components/profiler/src/profiler_dummy.rs index f645897f0cb..deeb27ecab4 100644 --- a/components/profiler/src/profiler_dummy.rs +++ b/components/profiler/src/profiler_dummy.rs @@ -1,11 +1,15 @@ // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. +/// Start profiling. Always returns false if `profiling` feature is not enabled. #[inline] -pub fn start(_name: impl AsRef) { +pub fn start(_name: impl AsRef) -> bool { // Do nothing + false } +/// Stop profiling. Always returns false if `profiling` feature is not enabled. #[inline] -pub fn stop() { +pub fn stop() -> bool { // Do nothing + false } diff --git a/components/profiler/src/profiler_linux.rs b/components/profiler/src/profiler_unix.rs similarity index 82% rename from components/profiler/src/profiler_linux.rs rename to components/profiler/src/profiler_unix.rs index 18d247acb1d..7b236369dbe 100644 --- a/components/profiler/src/profiler_linux.rs +++ b/components/profiler/src/profiler_unix.rs @@ -16,7 +16,7 @@ lazy_static::lazy_static! { static ref ACTIVE_PROFILER: Mutex = Mutex::new(Profiler::None); } -/// Start profiling. +/// Start profiling. Returns false if failed, i.e. there is already a profiling in progress. /// /// When `profiling` feature is not enabled, this function will do nothing and there is totally /// zero cost. @@ -26,12 +26,12 @@ lazy_static::lazy_static! { /// will be generated to the file specified by `name`. // TODO: Better multi-thread support. #[inline] -pub fn start(name: impl AsRef) { +pub fn start(name: impl AsRef) -> bool { let mut profiler = ACTIVE_PROFILER.lock().unwrap(); // Profiling in progress. if *profiler != Profiler::None { - return; + return false; } if valgrind_request::running_on_valgrind() != 0 { @@ -45,24 +45,28 @@ pub fn start(name: impl AsRef) { .start(name.as_ref()) .unwrap(); } + + true } -/// Stop profiling if it is started previously. +/// Stop profiling. Returns false if failed, i.e. there is no profiling in progress. /// /// When `profiling` feature is not enabled, this function will do nothing and there is totally /// zero cost. #[inline] -pub fn stop() { +pub fn stop() -> bool { let mut profiler = ACTIVE_PROFILER.lock().unwrap(); match *profiler { - Profiler::None => {} + Profiler::None => false, Profiler::CallGrind => { CallgrindClientRequest::stop(None); *profiler = Profiler::None; + true } Profiler::GPerfTools => { cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); *profiler = Profiler::None; + true } } } From e22fe777e493fccb8ecf04b67c8600b2f5cd7e26 Mon Sep 17 00:00:00 2001 From: Breezewish Date: Mon, 29 Apr 2019 00:41:19 +0800 Subject: [PATCH 9/9] Upgrade dependency Signed-off-by: Breezewish --- Cargo.lock | 38 +++++++++++++++++----------------- components/profiler/Cargo.toml | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bdd09b7a21f..8302b5c8ee5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,7 +312,7 @@ dependencies = [ "criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -347,7 +347,7 @@ dependencies = [ "crossbeam-deque 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-epoch 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -399,7 +399,7 @@ dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -413,7 +413,7 @@ dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -426,7 +426,7 @@ dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -453,7 +453,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -657,7 +657,7 @@ dependencies = [ "cargo_metadata 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -792,7 +792,7 @@ version = "0.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arbitrary 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -977,7 +977,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1374,7 +1374,7 @@ version = "0.0.1" dependencies = [ "callgrind 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "tikv_alloc 0.1.0", "valgrind_request 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1400,7 +1400,7 @@ name = "prometheus-static-metric" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1560,7 +1560,7 @@ name = "rand_chacha" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1590,7 +1590,7 @@ name = "rand_hc" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1638,7 +1638,7 @@ name = "rand_xorshift" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1666,7 +1666,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1875,7 +1875,7 @@ version = "0.1.0" source = "git+https://github.com/breeswish/slog-global.git?rev=91904ade#91904adec6e602df234e30560e98ef281d81eb84" dependencies = [ "arc-swap 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2153,7 +2153,7 @@ name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2420,7 +2420,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2843,7 +2843,7 @@ dependencies = [ "checksum kvproto 0.0.1 (git+https://github.com/pingcap/kvproto.git)" = "" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" -"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" +"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74" "checksum libfuzzer-sys 0.1.0 (git+https://github.com/rust-fuzz/libfuzzer-sys.git)" = "" diff --git a/components/profiler/Cargo.toml b/components/profiler/Cargo.toml index 3f472f95a2d..4b1f9e9b07d 100644 --- a/components/profiler/Cargo.toml +++ b/components/profiler/Cargo.toml @@ -11,7 +11,7 @@ profiling = ["lazy_static", "cpuprofiler", "callgrind", "valgrind_request"] tikv_alloc = { path = "../tikv_alloc" } [target.'cfg(unix)'.dependencies] -lazy_static = { version = "1.2.0", optional = true } +lazy_static = { version = "1.3.0", optional = true } cpuprofiler = { version = "0.0.3", optional = true } callgrind = { version = "1.1.0", optional = true } valgrind_request = { version = "1.1.0", optional = true }