Skip to main content

spawn_worker_v2

Function spawn_worker_v2 

Source
pub fn spawn_worker_v2(
    index: Arc<dyn MetadataIndex>,
    config: PrefetchConfig,
    fetcher: Arc<dyn PrefetchFetcher>,
    emit_outcome: Arc<dyn Fn(&PrefetchFetchOutcome) + Send + Sync>,
) -> PrefetchWorker
Expand description

Spawn the v2 worker that actually fetches the top-K each cycle.

Per cycle:

  1. Snapshot the metadata index + score per RFC 0008 ยง6.
  2. Take top-K candidates.
  3. Filter out candidates already present in the local flat cache.
  4. For each remaining: call fetcher.fetch_block(namespace, key) sequentially. On error, log + continue.
  5. Emit a per-cycle [MyelonInstr] event with detailed stage counts.

The fetch loop is sequential by design. v3 may parallelize via std::thread::scope when cycle-time becomes a bottleneck, see module docs.