Skip to content
Open
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
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ jobs:
- name: Clean up
run: sudo chown -R $USER:$USER . ~/.cargo

windows-build:
runs-on: windows-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: true
- name: "Install rust-toolchain.toml"
run: rustup toolchain install
- name: Add Windows GNU target
run: rustup target add x86_64-pc-windows-gnu
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2
- name: Check codspeed-runner builds on Windows
# Instrument hooks fails to build with msvc target, so we use the gnu target for this check for now
run: cargo check -p codspeed-runner --target x86_64-pc-windows-gnu

benchmarks:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ shell-words = "1.1.0"
rmp-serde = "1.3.0"
uuid = { version = "1.21.0", features = ["v4"] }
which = "8.0.2"
dirs = "6.0.0"

[target.'cfg(target_os = "linux")'.dependencies]
procfs = "0.17.0"
Expand Down Expand Up @@ -129,6 +130,11 @@ lto = "thin"
strip = true

[package.metadata.dist]
targets = ["aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl"]
targets = [
"aarch64-apple-darwin",
"aarch64-unknown-linux-musl",
"x86_64-unknown-linux-musl",
]
binaries.aarch64-apple-darwin = ["codspeed"]
binaries.aarch64-unknown-linux-musl = ["codspeed"]
binaries.x86_64-unknown-linux-musl = ["codspeed"]
1 change: 1 addition & 0 deletions crates/exec-harness/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fn main() {
core_c: instrument_hooks_dir.join("dist/core.c"),
includes_dir: instrument_hooks_dir.join("includes"),
};
println!("cargo:rerun-if-changed={}", paths.core_c.display());
paths.check_sources_exist();
build_shared_library(&paths, &preload_constants);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/instrument-hooks-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ mod other_impl {
pub struct InstrumentHooks;

impl InstrumentHooks {
pub fn instance() -> &'static Self {
pub fn instance(_integration: &str, _version: &str) -> &'static Self {
static INSTANCE: InstrumentHooks = InstrumentHooks;
&INSTANCE
}
Expand Down
1 change: 0 additions & 1 deletion crates/runner-shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ itertools = { workspace = true }
log = { workspace = true }
rmp = "0.8.14"
rmp-serde = "1.3.0"
libc = { workspace = true }
zstd = "0.13"

[dev-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion crates/runner-shared/src/artifacts/memtrack.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use libc::pid_t;
use serde::{Deserialize, Serialize};

use crate::pid_t;
use std::io::{BufReader, BufWriter, Read, Write};

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
3 changes: 2 additions & 1 deletion crates/runner-shared/src/artifacts/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::io::BufReader;

use libc::pid_t;
use log::debug;

use crate::pid_t;
use serde::{Deserialize, Serialize};

mod execution_timestamps;
Expand Down
4 changes: 4 additions & 0 deletions crates/runner-shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ pub mod module_symbols;
pub mod perf_event;
pub mod unwind_data;
pub mod walltime_results;

/// Process ID type, equivalent to `libc::pid_t` on Unix.
#[allow(non_camel_case_types)]
pub type pid_t = i32;
3 changes: 2 additions & 1 deletion crates/runner-shared/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::Context;
use libc::pid_t;
use serde::{Deserialize, Serialize};

use crate::pid_t;
use std::collections::HashMap;
use std::io::BufWriter;
use std::path::Path;
Expand Down
16 changes: 16 additions & 0 deletions scripts/sync-to-local.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Syncs the repo from the shared folder (Z:\) to a local working copy.
#
# Usage: powershell -ExecutionPolicy Bypass -File Z:\scripts\sync-to-local.ps1

$ErrorActionPreference = "Stop"

$syncs = @(
@{ SRC = "Z:\codspeed"; DST = "C:\Users\vboxuser\codspeed" },
@{ SRC = "Z:\codspeed-rust"; DST = "C:\Users\vboxuser\codspeed-rust" }
)

foreach ($sync in $syncs) {
# /MIR = mirror (copy + delete extras), /XD = exclude dirs, /MT = multi-threaded
robocopy $sync.SRC $sync.DST /MIR /MT /XD .git target target_win node_modules /NFL /NDL /NJH /NJS /NC /NS
Write-Host "Synced $($sync.SRC) -> $($sync.DST)"
}
95 changes: 66 additions & 29 deletions src/cli/setup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::executor::{ToolInstallStatus, get_all_executors};
use crate::executor::{ExecutorSupport, ToolInstallStatus, get_all_executors};
use crate::prelude::*;
use crate::system::SystemInfo;
use clap::{Args, Subcommand};
Expand All @@ -22,10 +22,7 @@ enum SetupCommands {
pub async fn run(args: SetupArgs, setup_cache_dir: Option<&Path>) -> Result<()> {
match args.command {
None => setup(setup_cache_dir).await,
Some(SetupCommands::Status) => {
status();
Ok(())
}
Some(SetupCommands::Status) => status(),
}
}

Expand All @@ -34,41 +31,81 @@ async fn setup(setup_cache_dir: Option<&Path>) -> Result<()> {
let executors = get_all_executors();
start_group!("Setting up the environment for all executors");
for executor in executors {
info!(
"Setting up the environment for the executor: {}",
executor.name()
);
executor.setup(&system_info, setup_cache_dir).await?;
match executor.support_level(&system_info) {
ExecutorSupport::Unsupported => {
info!(
"Skipping setup for the {} executor: not supported on {}",
executor.name(),
system_info.os
);
}
ExecutorSupport::RequiresManualInstallation => {
info!(
"Skipping automatic setup for the {} executor on {}; install required tooling manually.",
executor.name(),
system_info.os
);
}
ExecutorSupport::FullySupported => {
info!(
"Setting up the environment for the executor: {}",
executor.name()
);
executor.setup(&system_info, setup_cache_dir).await?;
}
}
}
info!("Environment setup completed");
end_group!();
Ok(())
}

pub fn status() {
pub fn status() -> Result<()> {
let system_info = SystemInfo::new()?;
info!("{}", style("Tools").bold());
for executor in get_all_executors() {
let tool_status = executor.tool_status();
match &tool_status.status {
ToolInstallStatus::Installed { version } => {
info!(" {} {} ({})", check_mark(), tool_status.tool_name, version);
}
ToolInstallStatus::IncorrectVersion { version, message } => {
info!(
" {} {} ({}, {})",
warn_mark(),
tool_status.tool_name,
version,
message
);
}
ToolInstallStatus::NotInstalled => {
// Don't probe for tooling that can't be used on this OS anyway.
if executor.support_level(&system_info) == ExecutorSupport::Unsupported {
continue;
}
match executor.tool_status() {
Some(tool_status) => match &tool_status.status {
ToolInstallStatus::Installed { version } => {
info!(
" {} {} executor: {} ({})",
check_mark(),
executor.name(),
tool_status.tool_name,
version
);
}
ToolInstallStatus::IncorrectVersion { version, message } => {
info!(
" {} {} executor: {} ({}, {})",
warn_mark(),
executor.name(),
tool_status.tool_name,
version,
message
);
}
ToolInstallStatus::NotInstalled => {
info!(
" {} {} executor: {} (not installed)",
cross_mark(),
executor.name(),
tool_status.tool_name
);
}
},
None => {
info!(
" {} {} (not installed)",
cross_mark(),
tool_status.tool_name
" {} {} executor: No tool to install",
check_mark(),
executor.name()
);
}
}
}
Ok(())
}
7 changes: 2 additions & 5 deletions src/cli/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@ pub async fn run(api_client: &CodSpeedAPIClient) -> Result<()> {
info!("");

// Setup/tools status
super::setup::status();
super::setup::status()?;
info!("");

// System info
info!("{}", style("System").bold());
info!(" codspeed {VERSION}");
let system_info = SystemInfo::new()?;
info!(
" {} {} ({})",
system_info.os, system_info.os_version, system_info.arch
);
info!(" {} ({})", system_info.os, system_info.arch);
info!(
" {} ({}C / {}GB)",
system_info.cpu_brand, system_info.cpu_cores, system_info.total_memory_gb
Expand Down
9 changes: 2 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{env, fs, path::PathBuf};
use std::{fs, path::PathBuf};

use crate::prelude::*;
use nestify::nest;
Expand Down Expand Up @@ -28,12 +28,7 @@ nest! {
/// If config_name is None, returns ~/.config/codspeed/config.yaml (default)
/// If config_name is Some, returns ~/.config/codspeed/{config_name}.yaml
fn get_configuration_file_path(config_name: Option<&str>) -> PathBuf {
let config_dir = env::var("XDG_CONFIG_HOME")
.map(PathBuf::from)
.unwrap_or_else(|_| {
let home = env::var("HOME").expect("HOME env variable not set");
PathBuf::from(home).join(".config")
});
let config_dir = dirs::config_dir().expect("Could not determine config directory");
let config_dir = config_dir.join("codspeed");

match config_name {
Expand Down
4 changes: 2 additions & 2 deletions src/executor/helpers/apt.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use super::run_with_sudo::run_with_sudo;
use crate::prelude::*;
use crate::system::SystemInfo;
use crate::system::{SupportedOs, SystemInfo};
use std::path::Path;
use std::process::Command;

const METADATA_FILENAME: &str = "./tmp/codspeed-cache-metadata.txt";

fn is_system_compatible(system_info: &SystemInfo) -> bool {
system_info.os == "ubuntu" || system_info.os == "debian"
matches!(system_info.os, SupportedOs::Linux(ref distro) if distro.is_supported())
}

/// Installs packages with caching support.
Expand Down
29 changes: 19 additions & 10 deletions src/executor/helpers/env.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::executor::ExecutorConfig;
#[cfg(unix)]
use crate::executor::helpers::{introspected_golang, introspected_nodejs};
use crate::prelude::*;
use crate::runner_mode::RunnerMode;
Expand Down Expand Up @@ -82,17 +83,25 @@ pub fn build_path_env(enable_introspection: bool) -> Result<String> {
return Ok(path_env);
}

let node_path = introspected_nodejs::setup()
.map_err(|e| anyhow!("failed to setup NodeJS introspection. {e}"))?;
let go_path = introspected_golang::setup()
.map_err(|e| anyhow!("failed to setup Go introspection. {e}"))?;
#[cfg(unix)]
{
let node_path = introspected_nodejs::setup()
.map_err(|e| anyhow!("failed to setup NodeJS introspection. {e}"))?;
let go_path = introspected_golang::setup()
.map_err(|e| anyhow!("failed to setup Go introspection. {e}"))?;

Ok(format!(
"{}:{}:{}",
node_path.to_string_lossy(),
go_path.to_string_lossy(),
path_env,
))
Ok(format!(
"{}:{}:{}",
node_path.to_string_lossy(),
go_path.to_string_lossy(),
path_env,
))
}
#[cfg(not(unix))]
{
// Language introspection is not yet supported on non-Unix platforms
unimplemented!();
}
}

pub fn is_codspeed_debug_enabled() -> bool {
Expand Down
2 changes: 1 addition & 1 deletion src/executor/helpers/harvest_perf_maps_for_pids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tokio::fs;

pub async fn harvest_perf_maps_for_pids(
profile_folder: &Path,
pids: &HashSet<libc::pid_t>,
pids: &HashSet<runner_shared::pid_t>,
) -> Result<()> {
let perf_maps = pids
.iter()
Expand Down
6 changes: 4 additions & 2 deletions src/executor/helpers/introspected_golang/go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ if [ "${CODSPEED_RUNNER_MODE:-}" != "walltime" ]; then
exit 1
fi

# Find the real go binary, so that we don't end up in infinite recursion
REAL_GO=$(which -a go | grep -v "$(realpath "$0")" | head -1)
# Find the real go binary by removing our directory from PATH (same approach as node.sh)
ORIGINAL_PATH=$(echo "$PATH" | tr ":" "\n" | grep -v "codspeed_introspected_go" | tr "\n" ":")
REAL_GO=$(env PATH="$ORIGINAL_PATH" which go 2>/dev/null || true)
debug_log "Real go path: $REAL_GO"
if [ -z "$REAL_GO" ]; then
echo "ERROR: Could not find real go binary" >&2
exit 1
Expand Down
3 changes: 3 additions & 0 deletions src/executor/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ pub mod command;
pub mod detect_executable;
pub mod env;
pub mod get_bench_command;
#[cfg(unix)]
pub mod harvest_perf_maps_for_pids;
#[cfg(unix)]
pub mod introspected_golang;
#[cfg(unix)]
pub mod introspected_nodejs;
pub mod profile_folder;
pub mod run_command_with_log_pipe;
Expand Down
Loading
Loading