File tree Expand file tree Collapse file tree 5 files changed +36
-0
lines changed Expand file tree Collapse file tree 5 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ cargo build -p collector --bin rustc-fake
39
39
# oprofile: untested... it's not used much, and might have the same problems
40
40
# that `perf` has due to virtualized hardware.
41
41
42
+ # samply: untested because it has the same problems that `perf` has due to
43
+ # virtualized hardware.
44
+
42
45
# Cachegrind.
43
46
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
44
47
cargo run -p collector --bin collector -- \
Original file line number Diff line number Diff line change @@ -289,6 +289,13 @@ The mandatory `<PROFILER>` argument must be one of the following.
289
289
- ** Notes** . OProfile fails moderately often with this message: "operf-record
290
290
process killed by signal 13". The failures seem to be random; re-running
291
291
often results in success.
292
+ - ` samply ` : Profile with [ Samply] ( https://github.com/mstange/samply/ ) , a
293
+ sampling profiler.
294
+ - ** Purpose** . Samply is a general-purpose profiler, good for seeing
295
+ where execution time is spent and finding hot functions.
296
+ - ** Slowdown** . Negligible.
297
+ - ** Output** . Binary output is written to a file with a ` samply ` prefix.
298
+ That file can be loaded with ` samply load ` .
292
299
- ` cachegrind ` : Profile with
293
300
[ Cachegrind] ( http://valgrind.org/docs/manual/cg-manual.html ) , a tracing
294
301
profiler. Requires Valgrind 3.15 or later.
Original file line number Diff line number Diff line change @@ -230,6 +230,19 @@ fn main() {
230
230
run_with_determinism_env ( cmd) ;
231
231
}
232
232
233
+ "Samply" => {
234
+ let mut cmd = Command :: new ( "samply" ) ;
235
+ let has_samply = cmd. output ( ) . is_ok ( ) ;
236
+ assert ! ( has_samply) ;
237
+ cmd. arg ( "record" )
238
+ . arg ( "--no-open" )
239
+ . arg ( "--save-only" )
240
+ . arg ( & tool)
241
+ . args ( & args) ;
242
+
243
+ run_with_determinism_env ( cmd) ;
244
+ }
245
+
233
246
"Cachegrind" => {
234
247
let mut cmd = Command :: new ( "valgrind" ) ;
235
248
let has_valgrind = cmd. output ( ) . is_ok ( ) ;
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ impl PerfTool {
51
51
| ProfileTool ( SelfProfile )
52
52
| ProfileTool ( PerfRecord )
53
53
| ProfileTool ( Oprofile )
54
+ | ProfileTool ( Samply )
54
55
| ProfileTool ( Cachegrind )
55
56
| ProfileTool ( Callgrind )
56
57
| ProfileTool ( Dhat )
@@ -86,6 +87,7 @@ impl PerfTool {
86
87
| ProfileTool ( SelfProfile )
87
88
| ProfileTool ( PerfRecord )
88
89
| ProfileTool ( Oprofile )
90
+ | ProfileTool ( Samply )
89
91
| ProfileTool ( Cachegrind )
90
92
| ProfileTool ( Callgrind )
91
93
| ProfileTool ( Dhat )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ pub enum Profiler {
14
14
SelfProfile ,
15
15
PerfRecord ,
16
16
Oprofile ,
17
+ Samply ,
17
18
Cachegrind ,
18
19
Callgrind ,
19
20
Dhat ,
@@ -206,6 +207,16 @@ impl<'a> Processor for ProfileProcessor<'a> {
206
207
fs:: write ( opann_file, & op_annotate_cmd. output ( ) ?. stdout ) ?;
207
208
}
208
209
210
+ // Samply produces (via rustc-fake) a data file called
211
+ // `profile.json`. We copy it from the temp dir to the output dir,
212
+ // giving it a new name in the process.
213
+ Profiler :: Samply => {
214
+ let tmp_samply_file = filepath ( data. cwd . as_ref ( ) , "profile.json" ) ;
215
+ let samply_file = filepath ( self . output_dir , & out_file ( "samply" ) ) ;
216
+
217
+ fs:: copy ( & tmp_samply_file, & samply_file) ?;
218
+ }
219
+
209
220
// Cachegrind produces (via rustc-fake) a data file called `cgout`.
210
221
// We copy it from the temp dir to the output dir, giving it a new
211
222
// name in the process, and then post-process it to produce another
You can’t perform that action at this time.
0 commit comments