summaryrefslogtreecommitdiff
path: root/yjit/src/stats.rs
diff options
context:
space:
mode:
Diffstat (limited to 'yjit/src/stats.rs')
-rw-r--r--yjit/src/stats.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/yjit/src/stats.rs b/yjit/src/stats.rs
index f937c6e625..42b7de7a59 100644
--- a/yjit/src/stats.rs
+++ b/yjit/src/stats.rs
@@ -26,7 +26,9 @@ pub struct YjitExitLocations {
raw_samples: Vec<VALUE>,
/// Vec to hold line_samples which represent line numbers of
/// the iseq caller.
- line_samples: Vec<i32>
+ line_samples: Vec<i32>,
+ /// Number of samples skipped when sampling
+ skipped_samples: usize
}
/// Private singleton instance of yjit exit locations
@@ -47,7 +49,8 @@ impl YjitExitLocations {
let yjit_exit_locations = YjitExitLocations {
raw_samples: Vec::new(),
- line_samples: Vec::new()
+ line_samples: Vec::new(),
+ skipped_samples: 0
};
// Initialize the yjit exit locations instance
@@ -71,6 +74,11 @@ impl YjitExitLocations {
&mut YjitExitLocations::get_instance().line_samples
}
+ /// Get the number of samples skipped
+ pub fn get_skipped_samples() -> &'static mut usize {
+ &mut YjitExitLocations::get_instance().skipped_samples
+ }
+
/// Mark the data stored in YjitExitLocations::get_raw_samples that needs to be used by
/// rb_yjit_add_frame. YjitExitLocations::get_raw_samples are an array of
/// VALUE pointers, exit instruction, and number of times we've seen this stack row
@@ -573,6 +581,15 @@ pub extern "C" fn rb_yjit_record_exit_stack(exit_pc: *const VALUE)
return;
}
+ if get_option!(trace_exits_sample_rate) > 0 {
+ if get_option!(trace_exits_sample_rate) <= *YjitExitLocations::get_skipped_samples() {
+ YjitExitLocations::get_instance().skipped_samples = 0;
+ } else {
+ YjitExitLocations::get_instance().skipped_samples += 1;
+ return;
+ }
+ }
+
// rb_vm_insn_addr2opcode won't work in cargo test --all-features
// because it's a C function. Without insn call, this function is useless
// so wrap the whole thing in a not test check.