Skip to content

Commit 2c2b018

Browse files
Prepare c0mpute 0.2.43 benchmark metadata release (#82)
* Prepare v0.2.43 benchmark metadata release * Benchmark automatically after self-update --------- Co-authored-by: Anthony Ettinger <anthony@profullstack.com>
1 parent 57c0506 commit 2c2b018

32 files changed

Lines changed: 89 additions & 48 deletions

File tree

‎Cargo.lock‎

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ members = [
2323
]
2424

2525
[workspace.package]
26-
version = "0.2.42"
26+
version = "0.2.43"
2727
edition = "2024"
2828
license = "MIT"
2929
repository = "https://github.com/profullstack/c0mpute"

‎apps/tui/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@c0mpute/tui",
3-
"version": "0.2.42",
3+
"version": "0.2.43",
44
"private": true,
55
"type": "module",
66
"bin": {

‎apps/web/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "c0mpute",
3-
"version": "0.2.42",
3+
"version": "0.2.43",
44
"private": true,
55
"type": "module",
66
"scripts": {

‎apps/web/src/app/releases/latest.json/route.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const dynamic = "force-dynamic";
2828
* this in sync with the workspace version in `Cargo.toml` on each release so a
2929
* freshly built CLI reports "already latest" rather than a phantom upgrade.
3030
*/
31-
const FALLBACK_VERSION = "0.2.42";
31+
const FALLBACK_VERSION = "0.2.43";
3232
const FALLBACK_MIN_REQUIRED = "0.0.1";
3333

3434
type Channel = "stable" | "beta" | "nightly";

‎node/crates/c0mpute-bench/src/lib.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,17 @@ fn host_info() -> (String, String, Option<u64>) {
607607
(cpu, kernel, ram_bytes)
608608
}
609609

610+
/// Current public host hardware summary for capability adverts. Bench reports
611+
/// remain the source of performance results, but this lets unbenchmarked nodes
612+
/// publish CPU, core count and installed memory too.
613+
pub fn hardware_summary() -> (String, usize, Option<u64>) {
614+
let (cpu, _kernel, ram_bytes) = host_info();
615+
let cores = std::thread::available_parallelism()
616+
.map(|n| n.get())
617+
.unwrap_or(1);
618+
(cpu, cores, ram_bytes)
619+
}
620+
610621
fn rfc3339_now() -> String {
611622
let secs = SystemTime::now()
612623
.duration_since(UNIX_EPOCH)

‎node/crates/c0mpute-cli/src/main.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ enum Cmd {
6363
/// Benchmark this machine (fib / matmul / hash at 1…N threads) and record
6464
/// a score the worker advertises to the network. Report lands in
6565
/// `<data-dir>/bench.json`, same shape as fleetcode's runtime-benchmarks.
66+
#[command(alias = "benchmark")]
6667
Bench {
6768
#[command(subcommand)]
6869
cmd: Option<BenchCmd>,

‎node/crates/c0mpute-core/src/capabilities.rs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,13 @@ pub fn hardware_blob(config: &Config) -> serde_json::Value {
143143
"version": env!("CARGO_PKG_VERSION"),
144144
"free_disk_root": config.storage.root.display().to_string(),
145145
});
146+
let (cpu, cores, ram_bytes) = c0mpute_bench::hardware_summary();
147+
blob["cpu"] = serde_json::Value::String(cpu);
148+
blob["cores"] = serde_json::Value::from(cores);
149+
if let Some(ram_bytes) = ram_bytes {
150+
blob["ram_bytes"] = serde_json::Value::from(ram_bytes);
151+
}
146152
if let Some(report) = bench_report_path().and_then(|p| c0mpute_bench::load(&p).ok().flatten()) {
147-
blob["cpu"] = serde_json::Value::String(report.metadata.cpu.clone());
148-
blob["cores"] = serde_json::Value::from(report.metadata.cores);
149-
if let Some(ram_bytes) = report.metadata.ram_bytes {
150-
blob["ram_bytes"] = serde_json::Value::from(ram_bytes);
151-
}
152153
blob["bench_at"] = serde_json::Value::String(report.metadata.start_time.clone());
153154
if !report.metadata.quick && report.score > 0 {
154155
blob["benchmark"] = benchmark_details(&report);

‎node/crates/c0mpute-update/src/lib.rs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,41 @@ pub async fn upgrade_now(current_version: &str, release_feed_url: &str) -> Resul
131131
current: current_version.to_string(),
132132
});
133133
}
134+
// Save the executable path before replacing its on-disk inode. After the
135+
// swap, launch the new binary's full benchmark under this node's identity
136+
// so its refreshed report is what the worker advertises on restart.
137+
let new_exe = std::env::current_exe().ok();
134138
perform_upgrade(&manifest).await?;
139+
if let Some(exe) = new_exe {
140+
if let Err(error) = run_post_update_benchmark(exe).await {
141+
warn!(err = %error, "post-update benchmark failed; continuing with the updated binary");
142+
}
143+
} else {
144+
warn!("could not locate updated executable to run the post-update benchmark");
145+
}
135146
Ok(UpgradeOutcome::Upgraded {
136147
from: current_version.to_string(),
137148
to: manifest.version,
138149
})
139150
}
140151

152+
async fn run_post_update_benchmark(exe: std::path::PathBuf) -> Result<()> {
153+
let status = tokio::task::spawn_blocking(move || {
154+
std::process::Command::new(exe)
155+
.arg("benchmark")
156+
// The child already is the newly installed version; avoid another
157+
// release-feed request before it starts measuring this machine.
158+
.env("C0MPUTE_NO_AUTO_UPDATE", "1")
159+
.status()
160+
})
161+
.await
162+
.context("join post-update benchmark")??;
163+
if !status.success() {
164+
anyhow::bail!("`c0mpute benchmark` exited with {status}");
165+
}
166+
Ok(())
167+
}
168+
141169
/// Map the compile-time target to the release artifact's os/arch tokens
142170
/// (matching `.github/workflows/release.yml` naming).
143171
fn target_os_arch() -> Result<(&'static str, &'static str)> {

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "c0mpute-monorepo",
3-
"version": "0.2.42",
3+
"version": "0.2.43",
44
"private": true,
55
"workspaces": [
66
"apps/*",

0 commit comments

Comments
 (0)