Skip to content

[Paper/M2][P0] Add a shared FetchCoordinator with single-flight, priority, fairness, and cancellation #50

Description

@Ivanbeethoven

Parent research epic: #39

背景

在并发 workspace 中,相同 tree/blob 可能同时被多个请求触发。简单 worker pool 只能限制并发数,不能保证:

  • 相同对象只进行一次物理请求;
  • demand read 优先于后台 prefetch;
  • 单个 workspace 不占满队列;
  • unmount/refresh 后未使用请求及时取消;
  • 队列和内存有边界。

目标

在实际 Dicfuse/Antares 读取路径中加入全局协调器:

enum FetchKey {
    Tree { snapshot: SnapshotId, tree_oid: ObjectId },
    Blob { oid: ObjectId },
}

enum FetchPriority {
    DemandRead,
    DemandMetadata,
    BuildHint,
    BackgroundPrefetch,
}

Tasks

  • 新增 FetchCoordinator,替代分散的直接 HTTP fetch;
  • 对相同 FetchKey 实现 single-flight;
  • follower 共享 leader 结果,不复制完整 response buffer;
  • 使用有界队列,不使用无限增长 channel;
  • demand read/metadata 高于 prefetch;
  • 实现 per-workspace token/weight,避免 starvation;
  • 实现 host/global 并发和带宽上限;
  • workspace unmount、refresh 或 timeout 时取消无消费者请求;
  • 仅在仍有 waiter 时继续 shared fetch;
  • 集中 retry/backoff/rate-limit 处理;
  • 对 404/永久错误采用短期 negative cache,不能长期污染;
  • 与 Issue 4 CAS 联动,先查 CAS 再进入远端队列;
  • 输出 logical requests、physical fetches、coalesced waiters、queue delay 和 bytes;
  • 实现 deterministic fake backend 进行调度测试。

Acceptance Criteria

  • 64 个 workspace 同时冷读同一 blob,只产生一次物理 backend 请求;
  • 相同 tree listing 也可合并;
  • demand read 不会被大量 prefetch 长时间阻塞;
  • 任一 workspace 持续发请求时,其他 workspace 仍能获得进展;
  • queue length 和 in-flight bytes 有硬上限;
  • 取消一个 workspace 不会错误取消仍被其他 workspace 使用的 fetch;
  • retry 不会产生 duplicate publication;
  • 可导出 request-coalescing ratio 和 per-workspace fairness 指标。

Paper Measurements

  • logical/physical request ratio;
  • network bytes saved;
  • queue P50/P95/P99;
  • throughput vs workspace count;
  • fairness/Jain index;
  • cancellation savings;
  • single-flight ablation。

Relevant Files

src/dicfuse/store.rs
src/dicfuse/async_io.rs
src/manager/fetch.rs
src/dicfuse/manager.rs

Dependencies

Issue 1、Issue 4。可与 Issue 5–6 并行。


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions