Two fluid.bufcompose~ questions (Threads <> Time)

Hello !!

---- It takes a very long time concatenating, and mixing (?), buffers together onto a one long buffers.
When should I use the “reset” and “destgain” commands ?
It is faster to provide the overall length of the target buffer beforewards. But it is still rather slow for some reason.

---- I do not fully understand how the thread, “blocking” attr, is working.:

  • “blocking 0” -> Why not “@queue 1” by default ? It is still blocking periodically.
  • I had the impression it was faster to use “blocking 1” and make a queue system within max ?
  • Is “reset” erasing the QUEUE stack ?
  • “blocking 1” -> “fluid.bufcompose~: already processing” even with “@queue 1”
  • “blocking 2” -> no error message even with “@queue 0”. Is there a stack, a “@queue 1” when blocking = 2 ?

I made here is a “clear” patch to try to describe my questions:


----------begin_max5_patcher----------
3775.3oc0cs0jiZiE94d9UnxUp7PR2dQBIAL0lq0N0topslY2jIadHyVcgMp
cSFLvB3dZmTI+1WIDXC1bQfELNtpwdZ.iz46bz24hjv+1KtYwpnmYoK.uD7y
fat42dwM2jeHwAto3uuYwV2mWG3lleYKVGscKKLawsxykwdNK+32A9Nvitdf
rGY.+swIrzT+nPfeF3CtofGbSyXIfrHvtTF3cKVEDs989ga.v2s.3F5A159d
FvE7+1w1w.o64W8VvG7ydzOjepmAeUY6E3GxVGsKLuQQEGTzZ79jaFuEuuwq
Hb21ncYArrbgvn3n9d4c8nU+xcPKyxl3gnvrP2sr7y8MI9tAfuMJvq7zwtYq
4cqM2mvVmIQNnoEcows.SSi7OfVhOP72A+2ic.+vx1GJN1u+hWHd61KD243c
3hdwAbm3f3lsNJHJQJN4Bww2fUDiZHFpJhk5+q4HFBuzX7.IzbI4V.NG+HNR
LcNPQ3hgAPNNTCKarIWyiHXmaU7PsBkFZGJo45NIRhr0ORtZWVVTXyvFrIQD
drylvkDNcv8rP2UArp.s7ljsOlIkhEqbC2r3PutA4Dkakffh2sIkuO8VLnOt
VLTGsawfLvGG7MElLc35Hk6SPPdkwcGvRbSEtFDdR92+3q9wWARybW+9i9.5
mLmh0.YNL2lh6XP9w7fDUbMh3XwceIHLhiHIQ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RR2R
EOKV5vGFUEJXKcvJZoByjkN7qPUgpmpindUp9FXcXkapR.1ZoPJJQ5ZOSoLf
6uJJxJmexOILh17jeJXN4mAly+Ifo8e9WN8m9k7c3ea+ju7he+E+eXLjjs.
-----------end_max5_patcher-----------

The queue could be on by default, but our preference was to preserve the historical behaviour as default, at least to start with. In any case, for big jobs, the copying to-and-from Max to worker thread still happens on the Max main thread, so it won’t completely aleviate any potential spinning wheels. For bufcompose , blocking 0 rarely (if ever) makes sense, because it’s doing the same amount of work (r more) launching the thread as the object would be doing anyway.

  • I had the impression it was faster to use “blocking 1” and make a queue system within max ?

I think this is due to the above

  • Is “reset” erasing the QUEUE stack ?

[cough] Good question. Possibly not

  • “blocking 1” -> “fluid.bufcompose~: already processing” even with “@queue 1”

Queuing has no effect in anything except blocking 0, I’ll see if I can make this clearer in the threading help tab. This is because in the modes, you have de facto queuing courtesy of Max. With that said, I’m surprised you saw that message in blocking 1, except if the message was coming from the scheduler thread into the object.

  • “blocking 2” -> no error message even with “@queue 0”. Is there a stack, a “@queue 1” when blocking = 2 ?

No: there’s the Max scheduler queue. I think that confirms what I just guessed: that the message you’re sending is coming from the scheduler thread. If you turn overdrive off (just to prove a point, not for real!), you’ll see different behaviour (no error message in either 1 or 2)

When should I use the
“reset”

If you want to return the object to the state it was in when created (i.e. all default parameter values, except what you entered into the box in Max)

“destgain” commands ?

When you want to mix incoming content into the destination, rather than overwriting

It is faster to provide the overall length of the target buffer beforewards. But it is still rather slow for some reason.

I’d meant to sit down with you at the plenary and go over this. In the patch you showed us with a speed problem, you’re pre-sizing the length with something like samps <n> but you’re actually writing to a multichannel buffer, yes? In that case, the buffer is still growing every time you bufcompose because the number of channels isn’t right.

So, what happens if you use the two argument version of that samps <frames> <channels>?

What should happen is that the buffer never needs to be resized on your successive calls because it is always big enough for the job at hand (i.e. it tests dest size >= needed size rather than dest size == needed size) . I would then expect it to be much faster, because the slow thing is the resize calls to Max, and the memory allocations that ensue.

1 Like