perf: the producer's group test is a mask, not a 64-bit division
`plan_partition()` only ever chooses powers of two for `time_stride`, and the comment there already claimed the test was cheap -- but the stride is a runtime value, so `tick % period` compiled to a real division that the hot loop paid once per channel per wire sample. The per-channel masks are built where the partition is already reacted to, and the shared clock's group end is computed once per sample instead of three times. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
ee660c14fd
commit
84c158ff21
3 files changed
+41
-10
No files matched your search
@@ -180,6 +180,15 @@ class Acquisition {
|
||||
/// once the slot's samples have all been pushed. One entry per channel, refilled every slot.
|
||||
std::vector<f32> math_sample_;
|
||||
std::vector<std::uint64_t> value_acc_n_;
|
||||
/// Per channel, `time_stride * stride[i] - 1`: the group boundary as a **mask**, so the
|
||||
/// innermost loop tests `(tick & mask) == mask` instead of `tick % period == period - 1`.
|
||||
/// The divisor is a runtime value, so that modulo compiled to a real 64-bit `div` once per
|
||||
/// channel per *wire* sample -- the filter reads every sample by design, so it was the
|
||||
/// producer's largest avoidable cost. Both factors are powers of two (`plan_partition()`
|
||||
/// doubles `time_stride` from 1, and every `stride[i]` is 1), which is what makes the mask
|
||||
/// equivalent; it is sized and filled with the accumulators below, so a re-plan cannot
|
||||
/// leave it addressing the previous partition's groups.
|
||||
std::vector<std::uint64_t> acc_mask_;
|
||||
double time_acc_ = 0.0;
|
||||
double abs_time_acc_ = 0.0;
|
||||
std::uint64_t time_acc_n_ = 0;
|
||||
|
||||
Reference in new issue
Block a user