MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / pp_spill_enter

Function pp_spill_enter

src/pipeline/pass_parallel.c:879–906  ·  view source on GitHub ↗

Latch spill mode (once) and open the store. The store is open BEFORE the * latch is visible: a peer that reads the latch must also find the store, or * it sees "nothing to park" while this worker is still opening files and runs * the futility cycle instead of joining the sweep (kernel, 16 GB budget, * 2026-09-13: the abort fired before the first sweep had logged). Never fails * the run: witho

Source from the content-addressed store, hash-verified

877 * the run: without a store the results simply stay in memory and the nap /
878 * futility path applies as before. */
879static void pp_spill_enter(extract_ctx_t *ec, const char *reason) {
880 if (!ec->pctx || !ec->pctx->spill_allowed || !pp_spill_allowed(ec)) {
881 return;
882 }
883 if (atomic_load_explicit(&ec->pctx->spill_mode, memory_order_acquire) != 0 ||
884 atomic_load_explicit(&ec->spill_unavailable, memory_order_relaxed) != 0) {
885 return;
886 }
887 cbm_mutex_lock(&ec->spill_mu);
888 if (atomic_load_explicit(&ec->pctx->spill_mode, memory_order_acquire) == 0 &&
889 atomic_load_explicit(&ec->spill_unavailable, memory_order_relaxed) == 0) {
890 if (!ec->pctx->spill) {
891 ec->pctx->spill =
892 cbm_result_spill_open(cbm_resolve_cache_dir(), ec->max_workers, ec->file_count);
893 }
894 size_t mb = (size_t)1024 * 1024;
895 cbm_log_warn("mem.spill.on", "reason", reason, "charged_mb",
896 itoa_log((int)(cbm_mem_charged() / mb)), "budget_mb",
897 itoa_log((int)(cbm_mem_budget() / mb)), "store",
898 ec->pctx->spill ? "open" : "unavailable");
899 if (ec->pctx->spill) {
900 atomic_store_explicit(&ec->pctx->spill_mode, 1, memory_order_release);
901 } else {
902 atomic_store_explicit(&ec->spill_unavailable, 1, memory_order_relaxed);
903 }
904 }
905 cbm_mutex_unlock(&ec->spill_mu);
906}
907
908static bool pp_spill_active(const extract_ctx_t *ec) {
909 /* The atomic gates the pointer, not the other way round. pp_spill_enter

Callers 3

extract_workerFunction · 0.85
cbm_parallel_extract_exFunction · 0.85

Calls 8

pp_spill_allowedFunction · 0.85
cbm_mutex_lockFunction · 0.85
cbm_result_spill_openFunction · 0.85
cbm_resolve_cache_dirFunction · 0.85
cbm_mem_chargedFunction · 0.85
cbm_mem_budgetFunction · 0.85
cbm_mutex_unlockFunction · 0.85
itoa_logFunction · 0.70

Tested by

no test coverage detected