| 614 | |
| 615 | #[cfg(unix)] |
| 616 | fn run(config: Config) -> Result<()> { |
| 617 | config.validate()?; |
| 618 | let parent = config |
| 619 | .output |
| 620 | .parent() |
| 621 | .filter(|p| !p.as_os_str().is_empty()) |
| 622 | .unwrap_or(Path::new(".")); |
| 623 | fs::create_dir_all(parent)?; |
| 624 | ensure!( |
| 625 | Command::new("git") |
| 626 | .arg("--version") |
| 627 | .output() |
| 628 | .map(|o| o.status.success()) |
| 629 | .unwrap_or(false), |
| 630 | "git is required for the Git comparison cases" |
| 631 | ); |
| 632 | let (fixtures, golden, bare) = prepare_fixtures(parent, &config)?; |
| 633 | let host_root = fixtures.path().join("host"); |
| 634 | let socket = fixtures.path().join("s.sock"); |
| 635 | ensure!( |
| 636 | socket.to_string_lossy().len() <= 100, // sun_path limit is 104; leave slack |
| 637 | "socket path too long for a Unix socket: {} — use a shorter --output directory", |
| 638 | socket.display() |
| 639 | ); |
| 640 | let state = Arc::new(DaemonState::new()); |
| 641 | let handle = state.register(host_root.clone()); |
| 642 | let repository = handle.repository_ref().repository_id; |
| 643 | handle.repository()?; // fail fast; the server would serve errors otherwise |
| 644 | let server = serve(state, host_root.clone(), socket.clone())?; |
| 645 | let east = east_paths(&config); |
| 646 | let east_bytes: usize = golden |
| 647 | .iter() |
| 648 | .filter(|f| east.contains(&f.path)) |
| 649 | .map(|f| f.content.len()) |
| 650 | .sum(); |
| 651 | |
| 652 | let mut samples = Vec::new(); |
| 653 | let result = (|| -> Result<()> { |
| 654 | for iteration in 0..config.warmups + config.iterations { |
| 655 | for case in CASES { |
| 656 | let partial = case.contains("partial"); |
| 657 | let sandbox = fixtures.path().join(format!("sandbox-{case}-{iteration}")); |
| 658 | // Store open is setup, not measured: the COW clone is the |
| 659 | // operation under test. |
| 660 | let cow_repo = (*case == "atomic_sandbox_cow").then(|| { |
| 661 | atomic_repository::Repository::open_existing_wait( |
| 662 | &host_root, |
| 663 | std::time::Duration::from_secs(30), |
| 664 | ) |
| 665 | .expect("open host repository") |
| 666 | }); |
| 667 | let started = Instant::now(); |
| 668 | let (phases, entries) = match *case { |
| 669 | "atomic_rpc_full" | "atomic_rpc_partial" => { |
| 670 | let target = libatomic::atomic::ViewRef { |
| 671 | view_id: Vec::new(), |
| 672 | name: Some("dev".into()), |
| 673 | }; |