Skip to content

Fix/buck2 isolation dir name#1913

Merged
benjamin-747 merged 3 commits into
gitmono-dev:mainfrom
jerry609:fix/buck2-isolation-dir-name
Feb 9, 2026
Merged

Fix/buck2 isolation dir name#1913
benjamin-747 merged 3 commits into
gitmono-dev:mainfrom
jerry609:fix/buck2-isolation-dir-name

Conversation

@jerry609

@jerry609 jerry609 commented Feb 9, 2026

Copy link
Copy Markdown
Collaborator

概述

修复 buck2 --isolation-dir 参数格式错误,并优化 FUSE 挂载场景下 buck2 启动时的元数据延迟。

根因

d3f4189 (#1908) 中对 --isolation-dir 的理解有误——它只接受纯目录名(如 buck2-isolation-abc123),不是完整路径。原实现拼接了 base 路径生成
/tmp/buck2-isolation-xxx,因包含 / 被 buck2 拒绝:

error: invalid value '/tmp/buck2-isolation-3d2852b569f25837'
for '--isolation-dir <ISOLATION_DIR>': isolation dir must be a directory name

这意味着 --isolation-dir 功能从引入以来从未真正生效过。

变更内容

1. 修复 --isolation-dir 参数格式

  • buck2_isolation_dir() 返回类型从 PathBuf 改为 String,只返回目录名
  • 删除 buck2_isolation_dir_base()parse_env_path() 及相关配置——buck2 内部管理 daemon 状态存放位置(<项目目录>/.buck2/<isolation_dir>/),base
    路径配置无实际效果
  • 简化 3 个调用点,移除多余的 .to_str() 转换
  • 清理 BuildConfig 中的 orion_buck2_isolation_dir_base 字段及所有 config.toml 中对应条目
  • 清理 .env.exampleDockerfile 中无用的 BUCK2_ISOLATION_DIR 环境变量

2. 降低 FUSE 冷启动元数据延迟

  • orion_preheat_shallow_depth 默认值从 0(禁用)改为 3,使 get_build_targets 路径有浅层预热
  • FUSE mount 增加 kernel_cache 选项,减少内核重复向用户态发请求
  • Antares FUSE 挂载的 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 参数进一步调优

Signed-off-by: jerry <1772030600@qq.com>
Signed-off-by: jerry <1772030600@qq.com>
Copilot AI review requested due to automatic review settings February 9, 2026 06:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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};

Copilot AI Feb 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
use crate::server::{mount_filesystem, mount_filesystem_with_antares_cache};
use crate::server::mount_filesystem_with_antares_cache;

Copilot uses AI. Check for mistakes.
Comment on lines +550 to +562
/// 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}"))

Copilot AI Feb 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot generated this review using guidance from repository custom instructions.
@benjamin-747

Copy link
Copy Markdown
Collaborator

@jerry609 请修改clippy 错误

@benjamin-747 benjamin-747 added this pull request to the merge queue Feb 9, 2026
Merged via the queue into gitmono-dev:main with commit 8cef669 Feb 9, 2026
19 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants