Repository navigation
Improve CLI binary lookup for tests - #1853
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let binary_name = format!("{name}{}", std::env::consts::EXE_SUFFIX); | ||
| let current_exe = env::current_exe().expect("current_exe should be available"); | ||
| let mut candidates = BTreeSet::new(); | ||
|
|
||
| let mut directory = current_exe.parent(); | ||
| while let Some(dir) = directory { | ||
| candidates.insert(dir.join(&binary_name)); | ||
|
|
||
| if dir | ||
| .file_name() | ||
| .and_then(|value| value.to_str()) | ||
| .is_some_and(|value| value == "target") | ||
| { | ||
| candidates.insert(dir.join("debug").join(&binary_name)); | ||
| candidates.insert(dir.join("release").join(&binary_name)); | ||
|
|
||
| if let Ok(entries) = fs::read_dir(dir) { | ||
| for entry in entries.flatten() { | ||
| if let Ok(file_type) = entry.file_type() { | ||
| if file_type.is_dir() { | ||
| let entry_path = entry.path(); | ||
| candidates.insert(entry_path.join(&binary_name)); | ||
| candidates.insert(entry_path.join("debug").join(&binary_name)); | ||
| candidates.insert(entry_path.join("release").join(&binary_name)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| directory = dir.parent(); | ||
| } | ||
|
|
||
| for candidate in candidates { | ||
| if candidate.is_file() { | ||
| return candidate; |
There was a problem hiding this comment.
Avoid lexicographic ordering when choosing candidate binaries
The new discovery loop fills a BTreeSet with possible binary paths and then returns the first candidate.is_file() match. Because a BTreeSet iterates in lexicographic order, a cross‑compiled artifact such as target/aarch64-unknown-linux-gnu/debug/oc-rsync will be inspected before the host’s target/debug/oc-rsync. After running cargo build --target <non-host> and then executing these tests on the host, the helper will attempt to run the foreign binary and the tests fail with Exec format error despite a valid host binary being present. The previous implementation preferred the binary adjacent to the current test executable and did not have this failure mode. Consider preserving the search order by using a Vec or scanning directories in priority order instead of a sorted set.
Useful? React with 👍 / 👎.
) Task #1853 verification. The concurrent_delta::ReorderBuffer was already converted to a Box<[Option<T>]> ring buffer in #1734 (with adaptive capacity scaling added in #3392), so the BTreeMap-vs-ring decision is already settled in production code. This change adds the scaling benchmark called for in #1853 to confirm O(1) per-item behaviour at the 10M-file scale that motivated the task, and corrects the stale "BTreeMap-backed" doc comment in the concurrent_delta module overview. The benchmark compares the production ring buffer against a self- contained BTreeMap baseline at 10K, 100K, 1M, and 10M items. The 10M case is gated behind BENCH_REORDER_10M=1 so default invocations stay fast; CI can opt in when targeting the scaling regression dataset. No production behaviour changes. Existing reorder_buffer tests already cover gap-larger-than-capacity (force_insert grows the ring) and ring wrap-around.
) Task #1853 verification. The concurrent_delta::ReorderBuffer was already converted to a Box<[Option<T>]> ring buffer in #1734 (with adaptive capacity scaling added in #3392), so the BTreeMap-vs-ring decision is already settled in production code. This change adds the scaling benchmark called for in #1853 to confirm O(1) per-item behaviour at the 10M-file scale that motivated the task, and corrects the stale "BTreeMap-backed" doc comment in the concurrent_delta module overview. The benchmark compares the production ring buffer against a self- contained BTreeMap baseline at 10K, 100K, 1M, and 10M items. The 10M case is gated behind BENCH_REORDER_10M=1 so default invocations stay fast; CI can opt in when targeting the scaling regression dataset. No production behaviour changes. Existing reorder_buffer tests already cover gap-larger-than-capacity (force_insert grows the ring) and ring wrap-around.
) Task #1853 verification. The concurrent_delta::ReorderBuffer was already converted to a Box<[Option<T>]> ring buffer in #1734 (with adaptive capacity scaling added in #3392), so the BTreeMap-vs-ring decision is already settled in production code. This change adds the scaling benchmark called for in #1853 to confirm O(1) per-item behaviour at the 10M-file scale that motivated the task, and corrects the stale "BTreeMap-backed" doc comment in the concurrent_delta module overview. The benchmark compares the production ring buffer against a self- contained BTreeMap baseline at 10K, 100K, 1M, and 10M items. The 10M case is gated behind BENCH_REORDER_10M=1 so default invocations stay fast; CI can opt in when targeting the scaling regression dataset. No production behaviour changes. Existing reorder_buffer tests already cover gap-larger-than-capacity (force_insert grows the ring) and ring wrap-around.
…#3827) Benchmark plan for cachegrind/perf profiling of BoundedReorderBuffer (crates/transfer/src/reorder_buffer.rs) at 1M files. Documents BTreeMap node layout, names the ring-buffer alternative from #1853, defines the three workloads (in-order, mostly-in-order with 5% gap, pathological), and pins L1d/LLC miss rate plus IPC as the decision metrics. Tracking task: oc-rsync #1854.
…#3827) Benchmark plan for cachegrind/perf profiling of BoundedReorderBuffer (crates/transfer/src/reorder_buffer.rs) at 1M files. Documents BTreeMap node layout, names the ring-buffer alternative from #1853, defines the three workloads (in-order, mostly-in-order with 5% gap, pathological), and pins L1d/LLC miss rate plus IPC as the decision metrics. Tracking task: oc-rsync #1854.
…#3827) Benchmark plan for cachegrind/perf profiling of BoundedReorderBuffer (crates/transfer/src/reorder_buffer.rs) at 1M files. Documents BTreeMap node layout, names the ring-buffer alternative from #1853, defines the three workloads (in-order, mostly-in-order with 5% gap, pathological), and pins L1d/LLC miss rate plus IPC as the decision metrics. Tracking task: oc-rsync #1854.
Summary
Testing