From 526a1a8acfe29f595b5e5f7cd12452cb1eaaa570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 1 Dec 2026 04:06:35 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20perf:=20Build=20&=20publish=20runs?= =?UTF-8?q?=20two=20lanes=20at=20once,=20This=20machine=20(Linux=20v1=20?= =?UTF-8?q?=E2=86=92=20v3)=20and=20Windows=20VM=20(prepare=20=E2=86=92=20v?= =?UTF-8?q?1=20=E2=86=92=20v3),=20so=20one=20lane's=20single-core=20LTO=20?= =?UTF-8?q?tail=20overlaps=20the=20other's=20parallel=20compile;=20cancel?= =?UTF-8?q?=20kills=20both.=20=F0=9F=92=84=20style:=20build=20rows=20group?= =?UTF-8?q?ed=20under=20lane=20headers,=20VM=20start=20step=20reads=20Prep?= =?UTF-8?q?are?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/lang/en/builder_release.txt | 2 + crates/client/lang/tr/builder_release.txt | 2 + crates/client/src/gui/builder/releases.rs | 41 +++++++++--- crates/client/src/release.rs | 80 +++++++++++++++-------- 4 files changed, 91 insertions(+), 34 deletions(-) diff --git a/crates/client/lang/en/builder_release.txt b/crates/client/lang/en/builder_release.txt index 269060f..000cf93 100644 --- a/crates/client/lang/en/builder_release.txt +++ b/crates/client/lang/en/builder_release.txt @@ -19,5 +19,7 @@ failed = Failed linux_v1 = Linux v1 linux_v3 = Linux v3 windows_vm = Windows VM +this_machine = This machine +prepare = Prepare windows_v1 = Windows v1 windows_v3 = Windows v3 diff --git a/crates/client/lang/tr/builder_release.txt b/crates/client/lang/tr/builder_release.txt index 3f72132..6edaf6d 100644 --- a/crates/client/lang/tr/builder_release.txt +++ b/crates/client/lang/tr/builder_release.txt @@ -19,5 +19,7 @@ failed = Başarısız linux_v1 = Linux v1 linux_v3 = Linux v3 windows_vm = Windows VM +this_machine = Bu makine +prepare = Hazırlık windows_v1 = Windows v1 windows_v3 = Windows v3 diff --git a/crates/client/src/gui/builder/releases.rs b/crates/client/src/gui/builder/releases.rs index 5555c6b..8a5ba3f 100644 --- a/crates/client/src/gui/builder/releases.rs +++ b/crates/client/src/gui/builder/releases.rs @@ -17,7 +17,7 @@ use crate::gui::{ text, }; use crate::lang::w; -use crate::release::{Build, Event, Job, Level, PLAN, is_source}; +use crate::release::{Build, Event, Job, LANES, Lane, Level, is_source}; const METER: f32 = 140.; @@ -95,12 +95,20 @@ fn job_label(job: Job) -> &'static str { match job { Job::Linux(Level::V1) => w.linux_v1, Job::Linux(Level::V3) => w.linux_v3, - Job::WindowsStart => w.windows_vm, + Job::WindowsStart => w.prepare, Job::Windows(Level::V1) => w.windows_v1, Job::Windows(Level::V3) => w.windows_v3, } } +fn lane_label(lane: Lane) -> &'static str { + let w = &w().builder_release; + match lane { + Lane::Host => w.this_machine, + Lane::Vm => w.windows_vm, + } +} + pub(super) fn caption_text(value: impl Into, color: Hsla) -> Div { div() .text_size(text(text::CAPTION)) @@ -346,11 +354,27 @@ impl Yumush { cx.notify(); }), ); - let rows: Vec
= self - .desk - .jobs + let lanes: Vec
= LANES .iter() - .map(|row| job_row(row, palette)) + .filter(|(_, jobs)| self.desk.jobs.iter().any(|row| jobs.contains(&row.job))) + .map(|(lane, jobs)| { + div() + .flex() + .flex_col() + .child( + list_row() + .text_size(text(text::LABEL)) + .text_color(palette.muted) + .child(lane_label(*lane)), + ) + .children( + self.desk + .jobs + .iter() + .filter(|row| jobs.contains(&row.job)) + .map(|row| job_row(row, palette).pl(px(space::XL))), + ) + }) .collect(); card(palette) @@ -368,7 +392,7 @@ impl Yumush { ) .child(choose), ) - .child(div().flex().flex_col().children(rows)) + .child(div().flex().flex_col().children(lanes)) .child( list_row().justify_between().child(required).child( div() @@ -483,8 +507,9 @@ impl Yumush { } let (build, mut events) = Build::start(source); self.desk.build = Some(build); - self.desk.jobs = PLAN + self.desk.jobs = LANES .iter() + .flat_map(|(_, jobs)| jobs.iter()) .map(|&job| Row { job, phase: Phase::Waiting, diff --git a/crates/client/src/release.rs b/crates/client/src/release.rs index 7803bfe..3b6b644 100644 --- a/crates/client/src/release.rs +++ b/crates/client/src/release.rs @@ -22,14 +22,26 @@ pub enum Job { Windows(Level), } -pub const PLAN: [Job; 5] = [ - Job::Linux(Level::V1), - Job::Linux(Level::V3), - Job::WindowsStart, - Job::Windows(Level::V1), - Job::Windows(Level::V3), +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Lane { + Host, + Vm, +} + +pub const LANES: [(Lane, &[Job]); 2] = [ + (Lane::Host, &[Job::Linux(Level::V1), Job::Linux(Level::V3)]), + ( + Lane::Vm, + &[ + Job::WindowsStart, + Job::Windows(Level::V1), + Job::Windows(Level::V3), + ], + ), ]; +type Slot = Arc>>; + #[derive(Debug, Clone, PartialEq)] pub enum Event { Started(Job), @@ -76,7 +88,7 @@ pub fn is_source(path: &Path) -> bool { pub struct Build { cancel: Arc, - child: Arc>>, + children: Vec, } impl Build { @@ -84,25 +96,31 @@ impl Build { let (tx, rx) = unbounded_channel(); let build = Self { cancel: Arc::default(), - child: Arc::default(), - }; - let cx = Cx { - tx, - cancel: build.cancel.clone(), - child: build.child.clone(), + children: LANES.iter().map(|_| Slot::default()).collect(), }; + let lanes: Vec = build + .children + .iter() + .map(|child| Cx { + tx: tx.clone(), + cancel: build.cancel.clone(), + child: child.clone(), + }) + .collect(); let running = Running::new(); thread::spawn(move || { let _running = running; - run(&source, &cx); + run(&source, &lanes); }); (build, rx) } pub fn cancel(&self) { self.cancel.store(true, Ordering::SeqCst); - if let Some(child) = self.child.lock().unwrap().as_mut() { - let _ = child.kill(); + for slot in &self.children { + if let Some(child) = slot.lock().unwrap().as_mut() { + let _ = child.kill(); + } } } } @@ -111,7 +129,7 @@ impl Build { struct Cx { tx: UnboundedSender, cancel: Arc, - child: Arc>>, + child: Slot, } impl Cx { @@ -131,23 +149,37 @@ enum Vm { Broken(String), } -fn run(source: &Path, cx: &Cx) { +fn run(source: &Path, lanes: &[Cx]) { let key = dirs::home_dir() .unwrap_or_default() .join("vm/yumush-win/id_ed25519"); + let first = &lanes[0]; let vm = match preflight(source) { Ok(vm) => vm, Err(e) => { - cx.send(Event::Failed(PLAN[0], e)); - cx.send(Event::Done); + first.send(Event::Failed(LANES[0].1[0], e)); + first.send(Event::Done); return; } }; - for job in PLAN { + thread::scope(|scope| { + for ((_, jobs), cx) in LANES.iter().zip(lanes) { + let (key, vm) = (&key, &vm); + scope.spawn(move || run_lane(jobs, source, key, cx, vm)); + } + }); + if let Vm::Started = vm { + podman_ok(&["stop", VM]); + } + first.send(Event::Done); +} + +fn run_lane(jobs: &[Job], source: &Path, key: &Path, cx: &Cx, vm: &Vm) { + for &job in jobs { let result = if cx.cancelled() { Err("cancelled".to_string()) } else { - run_job(job, source, &key, cx, &vm) + run_job(job, source, key, cx, vm) }; if let Err(e) = result { let e = if cx.cancelled() { @@ -159,10 +191,6 @@ fn run(source: &Path, cx: &Cx) { break; } } - if let Vm::Started = vm { - podman_ok(&["stop", VM]); - } - cx.send(Event::Done); } fn preflight(source: &Path) -> Result {