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
32 changes: 16 additions & 16 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ members = [
]

[workspace.package]
version = "0.2.68"
version = "0.2.69"
edition = "2024"
license = "MIT"
repository = "https://github.com/profullstack/c0mpute"
Expand Down
2 changes: 1 addition & 1 deletion apps/tui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@c0mpute/tui",
"version": "0.2.68",
"version": "0.2.69",
"private": true,
"type": "module",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "c0mpute",
"version": "0.2.68",
"version": "0.2.69",
"private": true,
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/releases/latest.json/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const dynamic = "force-dynamic";
* this in sync with the workspace version in `Cargo.toml` on each release so a
* freshly built CLI reports "already latest" rather than a phantom upgrade.
*/
const FALLBACK_VERSION = "0.2.68";
const FALLBACK_VERSION = "0.2.69";
const FALLBACK_MIN_REQUIRED = "0.0.1";

type Channel = "stable" | "beta" | "nightly";
Expand Down
64 changes: 64 additions & 0 deletions node/crates/c0mpute-core/src/diffusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,69 @@ fn node_slot() -> Arc<Semaphore> {
SLOT.get_or_init(|| Arc::new(Semaphore::new(1))).clone()
}

/// `/proc/<pid>/stat` -> (state, parent pid). The command name is in
/// parentheses and may contain spaces, so parse after the last `)`.
fn parse_stat(stat: &str) -> Option<(char, u32)> {
let rest = stat.get(stat.rfind(')')? + 1..)?.trim_start();
let mut fields = rest.split_whitespace();
let state = fields.next()?.chars().next()?;
let ppid = fields.next()?.parse().ok()?;
Some((state, ppid))
}

/// Kill renders left running by the binary this process replaced.
///
/// An auto-update re-executes the worker in place: same PID, so a running
/// sd-cli stays our child but nothing will ever read its result, and it
/// keeps ~6-9 GB and every core busy, so the node stops bidding (free-RAM
/// gate) or runs the next image at half speed. Called once when the runner
/// starts, before it takes any job, so every sd-cli child is such an orphan.
pub fn kill_orphaned_renders() -> usize {
if !cfg!(target_os = "linux") {
return 0;
}
let me = std::process::id();
let ours = sd_cli();
let Ok(entries) = std::fs::read_dir("/proc") else {
return 0;
};
let mut killed = 0;
for entry in entries.flatten() {
let name = entry.file_name();
let Some(pid) = name.to_str().and_then(|s| s.parse::<u32>().ok()) else {
continue;
};
let Ok(stat) = std::fs::read_to_string(format!("/proc/{pid}/stat")) else {
continue;
};
let Some((state, ppid)) = parse_stat(&stat) else {
continue;
};
if ppid != me || state == 'Z' {
continue;
}
if std::fs::read_link(format!("/proc/{pid}/exe")).ok().as_deref() != Some(ours.as_path()) {
continue;
}
if std::process::Command::new("kill")
.args(["-9", &pid.to_string()])
.status()
.is_ok_and(|s| s.success())
{
warn!(pid, "killed an sd-cli render orphaned by an in-place update");
killed += 1;
}
}
killed
}

pub fn spawn_diffusion_runner(
net: Arc<Libp2pNetwork>,
store: ChunkStore,
cache_root: PathBuf,
load: WorkerLoad,
) -> mpsc::Sender<AcceptedJob> {
kill_orphaned_renders();
let (tx, mut rx) = mpsc::channel::<AcceptedJob>(4);
tokio::spawn(async move {
while let Some(job) = rx.recv().await {
Expand Down Expand Up @@ -644,6 +701,13 @@ mod tests {
);
}

#[test]
fn proc_stat_parses_state_and_parent_even_with_spaces_in_the_name() {
assert_eq!(parse_stat("3655695 (sd-cli) R 4165541 3655695 0"), Some(('R', 4165541)));
assert_eq!(parse_stat("12 (a b) c) Z 7 12 0"), Some(('Z', 7)));
assert_eq!(parse_stat("garbage"), None);
}

#[test]
fn png_magic_is_checked() {
assert!(is_png(b"\x89PNG\r\n\x1a\n0000"));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "c0mpute-monorepo",
"version": "0.2.68",
"version": "0.2.69",
"private": true,
"workspaces": [
"apps/*",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@c0mpute/shared",
"version": "0.2.68",
"version": "0.2.69",
"private": true,
"type": "module",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion plugins/ad-generator-agent/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
[module]
id = "ad-generator-agent"
name = "Ad Generator Agent — every ad type from one URL"
version = "0.2.68"
version = "0.2.69"
kind = "service"
category = "applications"
status = "available"
Expand Down
2 changes: 1 addition & 1 deletion plugins/ads-manager/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[module]
id = "ads-manager"
name = "Ads Manager — shared ad operations layer"
version = "0.2.68"
version = "0.2.69"
kind = "service"
category = "applications"
status = "coming-soon"
Expand Down
2 changes: 1 addition & 1 deletion plugins/coinpay/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[module]
id = "coinpay"
name = "CoinPay — DID, payments, escrow, reputation"
version = "0.2.68"
version = "0.2.69"
kind = "service"
category = "applications"
status = "available"
Expand Down
2 changes: 1 addition & 1 deletion plugins/crawl/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[module]
id = "crawl"
name = "Crawl — distributed web fetching"
version = "0.2.68"
version = "0.2.69"
kind = "workload"
category = "data"
status = "available"
Expand Down
2 changes: 1 addition & 1 deletion plugins/ctv-ads/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[module]
id = "ctv-ads"
name = "CTV Ads — Connected TV ad marketplace"
version = "0.2.68"
version = "0.2.69"
kind = "service"
category = "applications"
status = "coming-soon"
Expand Down
2 changes: 1 addition & 1 deletion plugins/diffusion/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[module]
id = "diffusion"
name = "Diffusion — image generation"
version = "0.2.68"
version = "0.2.69"
kind = "workload"
category = "ai"
status = "available"
Expand Down
2 changes: 1 addition & 1 deletion plugins/embed/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[module]
id = "embed"
name = "Embeddings — vector generation"
version = "0.2.68"
version = "0.2.69"
kind = "workload"
category = "ai"
status = "coming-soon"
Expand Down
2 changes: 1 addition & 1 deletion plugins/gameserver/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[module]
id = "gameserver"
name = "Game server — Minecraft / Factorio / Valheim"
version = "0.2.68"
version = "0.2.69"
kind = "workload"
category = "infrastructure"
status = "coming-soon"
Expand Down
2 changes: 1 addition & 1 deletion plugins/hosting/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[module]
id = "hosting"
name = "Hosting — censorship-resistant static sites"
version = "0.2.68"
version = "0.2.69"
kind = "workload"
category = "data"
status = "coming-soon"
Expand Down
2 changes: 1 addition & 1 deletion plugins/infernet/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[module]
id = "infernet"
name = "Infernet Protocol — AI inference"
version = "0.2.68"
version = "0.2.69"
kind = "workload"
category = "ai"
status = "partial"
Expand Down
2 changes: 1 addition & 1 deletion plugins/live-stream/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
[module]
id = "live-stream"
name = "Live Stream — p2p HLS live streaming"
version = "0.2.68"
version = "0.2.69"
kind = "service"
category = "media"
status = "coming-soon"
Expand Down
2 changes: 1 addition & 1 deletion plugins/ocr/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[module]
id = "ocr"
name = "OCR — document text extraction"
version = "0.2.68"
version = "0.2.69"
kind = "workload"
category = "ai"
status = "coming-soon"
Expand Down
2 changes: 1 addition & 1 deletion plugins/podcast-ads/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
[module]
id = "podcast-ads"
name = "Podcast Ads — audio ad marketplace"
version = "0.2.68"
version = "0.2.69"
kind = "service"
category = "applications"
status = "coming-soon"
Expand Down
Loading
Loading