Expand description
Parallel corpus parse on top of the L2 LRU cache. ROADMAP L3
substrate; fans get_or_parse across cores with rayon while
preserving input order.
ROADMAP L3 - parallel parse across file corpus.
Fan out ParsedSourceLru::get_or_parse across all available cores via
rayon::par_iter. Corpus-wide deduplication still happens because each
unique (content, extra) pair is submitted to the cache exactly once;
duplicate entries in the input slice map back to the same Arc<T>.
§Design notes
- Ordering is preserved: the final sequential pass maps each input index
back to its parsed
Arc<T>. - The cache is
Send + Sync(backed byMutex<…>), so sharing a&ParsedSourceLru<T>across rayon workers is safe. parsemust beFn(&[u8]) -> T + Sync; the closure is invoked from multiple threads but never mutates shared state.- To avoid paying the parse cost multiple times for the same key under
concurrent cache misses (the L2 cache does not dedup in-flight parses),
the implementation first identifies unique keys, then calls
get_or_parseonce per unique key.
Functions§
- parse_
corpus_ parallel - Parse every
(content, extra_key)pair insourcesin parallel, memoising throughcache. ReturnsArc<T>values in input order.