-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
detectCycles performance #996
Comments
Hi Gerard, thanks for reporting this.
It's recursively tracing the graph. This could be very expensive for big graphs. But the function is also very small. It calls a few other functions though which makes me wonder if any of those could be the culprit. Could you try inspecting the performance profile again to check if any of those internal calls takes a disproportionate amount of time? Currently One optimization I could think of from the top of my head would be to not look for any cycles when connecting a source node to something else. This can never cause a cycle since a source node has no input. It's probably also what happens when you call |
Hi chrisguttandin, Thank you for your reply. This screenshot shows part of the performance trace for a triggerAttackRelease call on a Tone PolySynth. (The green detectCycles and (anonymous) blocks get repeated a lot more times as you scroll down). It seems like it is the detectCycles function itself that is causing the delay, rather than any other functions it calls. The anonymous entries are for the callback function in the Array.map call inside detectCycles. As you say, we get this pattern on all the calls to connect() - this is just one example. I would imagine that the audio graph is rather large by this point, but I am not aware of any easy ways to count or quantify it. I’m not sure if this is what you meant, but I have tried altering the
Do you have a link to the details of bug 164? I tried to search but couldn’t seem to find it, sorry! Many thanks for your help. Gerard |
Hi Gerard, thanks for the quick reply. These are the expectation tests for the bug in Chrome, Edge and Safari. I tried my best to tag every occurrence in the codebase with the same number. After taking a closer look at what's going on in Tone's The snippet that you included above handles connections to an Could you please also share the very bottom of the flame graph in the picture above. So far it looks like |
Hi chrisguttandin, Thanks for your message and the links to the expectation tests. I agree that each instance of detectCycles doesn’t seem to take very long, but I think in this case it is getting called so many times that it adds up! I tried to add a Its hard to capture the whole graph as it is quite tall, but I have tried to stitch it together: Zooming in a bit on the very bottom right shows this: My apologies that I wasn’t clear above, but I did add the As I said before, we are seeing this detectCycles pattern in various places, with this triggerAttackRelease call being just one example. So if there is anything that can be done to improve performance it would be great if it isn’t specific to just this. :) Thanks again for all your help, |
Hi there,
We have a complex application using Tone.js, which in turn uses standardized-audio-context underneath.
During performance testing we’ve noticed that a large amount of time is being spent inside a detectCycles recursive loop. For example, we are seeing that a triggerAttackRelease call on a synth can spend 80% of the processing time inside detectCycles.
Is there anything we can do to improve the performance of this functionality?
If we strip out standardized-audio-context completely the performance seems much improved, but obviously we are then losing the cross-browser standardisation provided.
Are you able to explain a bit more about when the detectCycles functionality is needed, and the browsers/problems it helps with? Can we do anything to reduce the number of times it gets called?
Many thanks for any info you can provide.
Regards,
Gerard
www.dappledark.com
The text was updated successfully, but these errors were encountered: