Proposal: SynthDefs could eliminate duplicate UGens

I’m not referring to CPU cache at all.

Without the UGenCache, r1 will end up as a Sum3 with a, b and c as inputs, and r2 as a different Sum3 with a, b and d as inputs.

With UGenCache (this is without testing – just guessing and writing on my phone), a + b would be done once on its own, and shared between r1 = that + c and r2 = that + d.

I don’t know which is more efficient. The pair of Sum3 units does 4 additions (one redundant) but only 2 calc function dispatches. The other way does one less addition but one more function dispatch. (But this is only an issue because the Sum3 optimization exists – I guess that conflicting optimizations could be hard to resolve.)

Tbh this is such a fine level of performance analysis that the vast majority of cases I’d guess would be indistinguishable in terms of speed.

hjh

1 Like