You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[PERF] Fix bugs, rule of five, and micro-optimizations
Bug fixes:
- SiPMProperties: setDXtOff() was clearing m_HasXt instead of m_HasDXt
- SiPMProperties: pdeSpectrum() returns const& (avoids map copy), pdeType() marked const
- SiPMAnalogSignal: constructor takes wav by value so std::move() is not a no-op
- SiPMAnalogSignal: integral()/peak() iterator off-by-one (skipped first sample, read past end)
- SiPMAnalogSignal: toa() guard against i==0 underflow when start sample exceeds threshold
- SiPMSensor: calculateSignalAmplitudes() uses hits[i-1]->time() for correct sequential recovery
Rule of Five:
- SiPMSmallVector: add copy/move constructor and assignment; compiler-generated shallow copy caused double-free on unordered_map rehash
Micro-optimizations (RNG hot path):
- Rand()/RandF(): generate raw integers directly into output vector buffer, eliminating sipmAlloc/sipmFree round-trip
- randGaussian()/randGaussianF(): merge 3-loop Box-Muller into single pass, compute sqrtR once per pair
Micro-optimizations (signal generation hot path):
- generateSignal(): pre-extract times/amplitudes into flat local arrays to batch pointer-chasing cache misses
- generateSignal(): add __builtin_prefetch for scattered SiPMHit* heap objects
- generateSignal(): use __restrict__ on inner loop pointers to enable AVX2 FMA vectorization
- addPhotons(): use assign() instead of copy-assignment to reuse existing vector capacity
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments