Forum

DO region performance

Question

Should DO regions affect performance?
My naive understanding of their purpose, (to enforce order of operations) made me think they would have no performance impact. Similar to using disabled IF regions for the same thing.

Usecase

  • I’m developing a sound library.
  • There are reactive requests for sound generated in the application
  • For example PlayMedia, PauseMedia etc
  • When these requests are received I want to enforce an order of operations, so that if PlayMedia and PauseMedia are sent in the same frame it’s clear which one will be executed first.
  • So my solution in the receiver is to use OfType to filter the requests to their downstream processes, and DO regions to enforce the order the OfType nodes can executed.

Demo

Tested in 2021.4.12

DoRegionTest
DoRegionTest.vl (125.2 KB)

Confirm same behaviour in 2021.4.13-1376

The Do Region is currently implemented with the custom region API which comes with a little overhead. Should that overhead really become a problem in a certain scenario we can think of implementing it differently.

Now to your patch, I’m not sure your approach is correct. You say if multiple requests arrive in one frame you want to handle them in a specific order. However that will not be the case in your sketches, because each sink will run through the incoming events on its own, the order of execution will be the same as how the events arrive. I’d suggest using the Sampler node which gives you all accumulated events as a spread which you then can order accordingly by either building a casting chain or introduce an interface on your request classes with a property you can order them by.

Ok

I guess I’m still misunderstanding something fundamental about how Reactive nodes relates to the rest of the patch in vvvv.

I understand the devvvs have decided on a way that reactive is represented in vvvv but I don’t understand all the parameters of that.
Until now why should I expect that a node in a region is not affected by the region? If that’s a rule with reactive it’s an important one and I missed it.

That could be one way to do it :

OrderedObservable.vl (62.9 KB)

1 Like

When patching with reactive nodes think of yourself as the plumber. You basically setup and connect the pipes with each other. In your example the Do regions only defined in what order the pipes get plugged into each other, they don’t say anything about how the water will run through them later on - does that make any sense?

@lecloneur Looks good

‘Think of yourself as a plumber’ is just a metaphor that equips me with some different assumptions. With hindsight it explains the current problem but it just means I run into a different problem tomorrow because it’s not the same as actual documentation of how this feature really works.

I find it confusing that the setup of streams is represented exactly the same as the flow of data in vvvv when it’s a different abstraction.