Fix/buck2 isolation dir name#1913
Conversation
Signed-off-by: jerry <1772030600@qq.com>
Signed-off-by: jerry <1772030600@qq.com>
Signed-off-by: jerry <1772030600@qq.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes Orion’s Buck2 --isolation-dir argument to comply with Buck2’s “directory name only” requirement, and reduces Buck2 cold-start metadata latency in Antares/Scorpio FUSE-mount scenarios by enabling shallow preheat and adding cache-related mount options.
Changes:
- Fix Buck2 isolation dir handling by generating a stable isolation name (not a full path) and removing the now-ineffective “base dir” configuration/env plumbing.
- Improve FUSE cold-start performance by enabling a default shallow preheat depth and applying cache-related FUSE mount options for Antares mounts.
- Clean up related configuration/templates (config TOMLs, Dockerfile,
.env.example) to match the new behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scorpio/src/server/mod.rs | Adds Antares-specific cache mount options and a new mount helper that can enable them. |
| scorpio/src/dicfuse/async_io.rs | Adds a TODO note for potential ENOENT negative lookup caching. |
| scorpio/src/antares/fuse.rs | Uses the new Antares-cache-enabled mount path for Antares FUSE. |
| orion/src/buck_controller.rs | Fixes --isolation-dir to be a directory name string; changes shallow preheat default to 3. |
| orion/Dockerfile | Removes unused Buck2 isolation env default. |
| orion/.env.example | Removes unused Buck2 isolation env example entry. |
| config/config.toml | Updates default shallow preheat depth and removes buck2 isolation base config. |
| config/config-workflow.toml | Same as above for workflow config. |
| config/config-test.toml | Same as above for test config. |
| common/src/config/mod.rs | Removes the orion_buck2_isolation_dir_base field from BuildConfig. |
| use tokio::task::JoinHandle; | ||
|
|
||
| use crate::server::mount_filesystem; | ||
| use crate::server::{mount_filesystem, mount_filesystem_with_antares_cache}; |
There was a problem hiding this comment.
mount_filesystem is imported here but no longer used in the non-test code path (the mount() implementation now calls mount_filesystem_with_antares_cache, and the remaining mount_filesystem references are via crate::server::... in the test module). This will trigger an unused import lint; remove mount_filesystem from this use list (or switch the test code to use the imported symbol).
| use crate::server::{mount_filesystem, mount_filesystem_with_antares_cache}; | |
| use crate::server::mount_filesystem_with_antares_cache; |
| /// Derive a stable per-mount buck2 isolation directory name. | ||
| /// | ||
| /// Buck2 `--isolation-dir` expects a plain directory **name** (no path | ||
| /// separators). Buck2 itself stores daemon state under | ||
| /// `<project_root>/.buck2/<isolation_dir>/`, so we only need to return a | ||
| /// unique name – not a full path. | ||
| fn buck2_isolation_dir(repo_path: &Path) -> anyhow::Result<String> { | ||
| let digest = ring::digest::digest( | ||
| &ring::digest::SHA256, | ||
| repo_path.to_string_lossy().as_bytes(), | ||
| ); | ||
| let suffix = &hex::encode(digest.as_ref())[..16]; | ||
| let (base, from_env) = buck2_isolation_dir_base(); | ||
| let mut path = base.join(format!("buck2-isolation-{suffix}")); | ||
| if let Err(err) = std::fs::create_dir_all(&path) { | ||
| if from_env { | ||
| tracing::warn!( | ||
| "Failed to create buck2 isolation dir {path:?} from ORION_BUCK2_ISOLATION_DIR_BASE: {err}. Falling back to temp dir." | ||
| ); | ||
| let fallback = std::env::temp_dir(); | ||
| path = fallback.join(format!("buck2-isolation-{suffix}")); | ||
| std::fs::create_dir_all(&path) | ||
| .map_err(|err| anyhow!("Failed to create buck2 isolation dir {path:?}: {err}"))?; | ||
| } else { | ||
| return Err(anyhow!( | ||
| "Failed to create buck2 isolation dir {path:?}: {err}" | ||
| )); | ||
| } | ||
| } | ||
| Ok(path) | ||
| Ok(format!("buck2-isolation-{suffix}")) |
There was a problem hiding this comment.
The behavior of buck2_isolation_dir() changed materially (now returns a plain dir name, and correctness depends on it containing no path separators and being stable for a given repo_path). There are tests in this file, but none cover this function. Add a small unit test asserting the returned value is stable and does not contain path separators (and ideally matches the expected buck2-isolation-<16 hex> pattern).
|
@jerry609 请修改clippy 错误 |
概述
修复 buck2
--isolation-dir参数格式错误,并优化 FUSE 挂载场景下 buck2 启动时的元数据延迟。根因
d3f4189 (#1908) 中对
--isolation-dir的理解有误——它只接受纯目录名(如buck2-isolation-abc123),不是完整路径。原实现拼接了 base 路径生成/tmp/buck2-isolation-xxx,因包含/被 buck2 拒绝:这意味着
--isolation-dir功能从引入以来从未真正生效过。变更内容
1. 修复
--isolation-dir参数格式buck2_isolation_dir()返回类型从PathBuf改为String,只返回目录名buck2_isolation_dir_base()、parse_env_path()及相关配置——buck2 内部管理 daemon 状态存放位置(<项目目录>/.buck2/<isolation_dir>/),base路径配置无实际效果
.to_str()转换BuildConfig中的orion_buck2_isolation_dir_base字段及所有 config.toml 中对应条目.env.example和Dockerfile中无用的BUCK2_ISOLATION_DIR环境变量2. 降低 FUSE 冷启动元数据延迟
orion_preheat_shallow_depth默认值从 0(禁用)改为 3,使get_build_targets路径有浅层预热kernel_cache选项,减少内核重复向用户态发请求entry_timeout/attr_timeout设为 60s(匹配antares_dicfuse_reply_ttl_secs),减少重复 lookup/getattr 调用3. 标记后续优化 TODO
在代码中标记了三处后续优化方向:
orion/src/buck_controller.rs:415— 定向预热(仅预热 buck2 需要的路径而非全树ls -lR)scorpio/src/dicfuse/async_io.rs:177— ENOENT 负查询缓存scorpio/src/server/mod.rs:63— FUSE mount 参数进一步调优