Template Function sequant::log::working_set_given

Function Documentation

template<typename N, bool F>
inline size_t sequant::log::working_set_given(CacheManager<N, F> const &cache, size_t own_bytes, ResultPtr const &a, ResultPtr const &b = {}, ResultPtr const &c = {})

The live working set of one op, in bytes: what a per-op trace event passes to CacheManager::note_working_set. It is

own_bytes + cache.outer_residency() + bytes of each buffer that is not already counted

where own_bytes is the evaluating cache’s own residency, outer_residency() is everything else resident at that scope (the ancestors’ entries and the externally held values, i.e. the ordered executor’s cell registry – at the outermost scope too), and the buffers are the op’s result and operands. A buffer is skipped when it is null, when CacheManager::resident() finds it – by pointer identity – among the values the residency already counts (an operand read whole from a cache at any scope, or from the registry), or when it is the same object as an earlier buffer in the list (an in-place result, a value used as both operands). A sliced / permuted / phase-shifted read is a distinct buffer and is added.

Every sampling site goes through here so the three terms are assembled the same way everywhere. Like the cache-aware bytes(), it short-circuits to 0 – walking no cache and no registry – when no trace line will be printed.