Skip to content

Commit 07df26e

Browse files
committed
perf: experiment with turning off run time cache
1 parent c15f8ff commit 07df26e

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

profiling/build.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,8 @@ fn cfg_preload(vernum: u64) -> bool {
322322

323323
fn cfg_run_time_cache(vernum: u64) -> bool {
324324
println!("cargo::rustc-check-cfg=cfg(php_run_time_cache)");
325-
if vernum >= 80000 {
326-
println!("cargo:rustc-cfg=php_run_time_cache");
327-
true
328-
} else {
329-
false
330-
}
325+
let _ = vernum;
326+
false
331327
}
332328

333329
fn cfg_trigger_time_sample() -> bool {

profiling/src/profiling/stack_walking.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,36 @@ mod detail {
483483
let mut execute_data_ptr = top_execute_data;
484484

485485
while let Some(execute_data) = unsafe { execute_data_ptr.as_ref() } {
486+
// allowed because it's only used on the frameless path
487+
#[allow(unused_variables)]
488+
if let Some(func) = unsafe { execute_data.func.as_ref() } {
489+
// It's possible that this is a fake frame put there by the
490+
// engine, see accel_preload on PHP 8.4 and the local variable
491+
// `fake_execute_data`. The frame is zeroed in this case, so
492+
// we can check for null.
493+
#[cfg(php_frameless)]
494+
if !func.is_internal() {
495+
if let Some(opline) = safely_get_opline(execute_data) {
496+
match opline.opcode as u32 {
497+
ZEND_FRAMELESS_ICALL_0
498+
| ZEND_FRAMELESS_ICALL_1
499+
| ZEND_FRAMELESS_ICALL_2
500+
| ZEND_FRAMELESS_ICALL_3 => {
501+
let func = unsafe {
502+
&**zend_flf_functions.offset(opline.extended_value as isize)
503+
};
504+
samples.try_push(ZendFrame {
505+
function: extract_function_name(func).unwrap(),
506+
file: None,
507+
line: 0,
508+
})?;
509+
}
510+
_ => {}
511+
}
512+
}
513+
}
514+
}
515+
486516
let maybe_frame = unsafe { collect_call_frame(execute_data) };
487517
if let Some(frame) = maybe_frame {
488518
samples.try_push(frame)?;

0 commit comments

Comments
 (0)