Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/executor/helpers/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ pub fn get_base_injected_env(
env
}

/// Set the env variable to not warn users about Go's perf unwinding mode when running Go benchmarks
pub fn suppress_go_perf_unwinding_warning() {
// Safety: no multithreading
unsafe {
std::env::set_var("CODSPEED_GO_SUPPRESS_PERF_UNWINDING_MODE_WARNING", "true");
}
}

pub fn is_codspeed_debug_enabled() -> bool {
std::env::var("CODSPEED_LOG")
.ok()
Expand Down
5 changes: 5 additions & 0 deletions src/executor/helpers/introspected_golang/go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ if [ $# -eq 0 ]; then
exit $?
fi

# On arm64, warn about setting CODSPEED_PERF_UNWINDING_MODE to "fp" for correct flamegraphs
if [ "$(uname -m)" = "aarch64" ] && [ "${CODSPEED_GO_SUPPRESS_PERF_UNWINDING_MODE_WARNING:-}" != "true" ]; then
echo "::warning::Go profiling on arm64 require frame pointer unwinding. Set CODSPEED_PERF_UNWINDING_MODE=fp for better profiling." >&2
fi

# Route command based on first argument
case "$1" in
test)
Expand Down
8 changes: 7 additions & 1 deletion src/executor/wall_time/perf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::cli::UnwindingMode;
use crate::executor::ExecutorConfig;
use crate::executor::helpers::command::CommandBuilder;
use crate::executor::helpers::env::is_codspeed_debug_enabled;
use crate::executor::helpers::env::suppress_go_perf_unwinding_warning;
use crate::executor::helpers::harvest_perf_maps_for_pids::harvest_perf_maps_for_pids;
use crate::executor::helpers::run_command_with_log_pipe::run_command_with_log_pipe_and_callback;
use crate::executor::helpers::run_with_sudo::run_with_sudo;
Expand Down Expand Up @@ -98,6 +99,8 @@ impl PerfRunner {
(mode, None)
} else if config.command.contains("cargo") {
(UnwindingMode::Dwarf, None)
} else if config.command.contains("go test") {
(UnwindingMode::FramePointer, None)
} else if config.command.contains("pytest")
|| config.command.contains("uv")
|| config.command.contains("python")
Expand All @@ -112,7 +115,10 @@ impl PerfRunner {
};

let cg_mode = match cg_mode {
UnwindingMode::FramePointer => "fp",
UnwindingMode::FramePointer => {
suppress_go_perf_unwinding_warning();
"fp"
}
UnwindingMode::Dwarf => &format!("dwarf,{}", stack_size.unwrap_or(8192)),
};
debug!("Using call graph mode: {cg_mode:?}");
Expand Down
Loading