diff --git a/vendored/libfuse/include/thread_pool.hpp b/vendored/libfuse/include/thread_pool.hpp index 92a66648..790f5308 100644 --- a/vendored/libfuse/include/thread_pool.hpp +++ b/vendored/libfuse/include/thread_pool.hpp @@ -1067,14 +1067,16 @@ ThreadPool::tasks_completed() const } // Approximate: the two counters are loaded non-atomically with -// relaxed ordering, so the result may momentarily read zero (or -// a lower value) while tasks complete between the two loads. +// relaxed ordering. Loading completed first biases the result +// toward zero (a completion between the two loads lowers the +// delta), which is safer for scaling heuristics than over- +// reporting pressure. // Suitable for monitoring and heuristics, not for synchronization. inline std::uint64_t ThreadPool::tasks_pending() const { - auto e = _tasks_enqueued.load(std::memory_order_relaxed); auto c = _tasks_completed.load(std::memory_order_relaxed); + auto e = _tasks_enqueued.load(std::memory_order_relaxed); return (e > c) ? (e - c) : 0; }