diff --git a/include/bitcoin/database/impl/memory/mmap_staging.ipp b/include/bitcoin/database/impl/memory/mmap_staging.ipp index c3d053f63..0e8cd343e 100644 --- a/include/bitcoin/database/impl/memory/mmap_staging.ipp +++ b/include/bitcoin/database/impl/memory/mmap_staging.ipp @@ -938,10 +938,15 @@ void CLASS::settler_run_() NOEXCEPT } #endif +#if !defined(HAVE_APPLE) // Scarcity is read directly: clean cache is reclaimable, so the // kernel pressure level does not raise while free memory exhausts. + // Apple is excluded: the sweep corrects linux victim selection, and + // ubc/compressor reclaim measured competent without it (its free + // signal is also perpetually low on darwin, running the sweep hot). if (system_free() < scarce) evict_next_(sweep); +#endif auto bytes = backlog(); if (is_zero(bytes)) @@ -998,6 +1003,7 @@ void CLASS::head_run_() NOEXCEPT still = (top == mark) ? std::min(add1(still), idle_seconds) : zero; mark = top; +#if !defined(HAVE_APPLE) // Touch pass: assert working-set residency at a bounded rate. // Hash-uniform probing is per-page sparse in every phase, so the // kernel ages head pages cold and swaps them under cache pressure, @@ -1041,6 +1047,7 @@ void CLASS::head_run_() NOEXCEPT } } } +#endif // !HAVE_APPLE if ((still < idle_seconds) || (transferred == top)) continue; diff --git a/include/bitcoin/database/memory/settings.hpp b/include/bitcoin/database/memory/settings.hpp index 43508a81f..2d3879aa5 100644 --- a/include/bitcoin/database/memory/settings.hpp +++ b/include/bitcoin/database/memory/settings.hpp @@ -60,8 +60,14 @@ struct storage_settings /// scattered: they are far too large to reside, and validation reads /// prevouts from arbitrary earlier blocks, so read-ahead manufactures /// cache that is never used and displaces the resident head set. Heads - /// override to random (preloaded) at construction. + /// override to random (preloaded) at construction. Apple retains normal + /// (its measured known-good): darwin fault clustering serves scattered + /// prevout reads that MADV_RANDOM would reduce to single-page faults. +#if defined(HAVE_APPLE) + advice access{ advice::normal }; +#else advice access{ advice::scattered }; +#endif }; } // namespace database