Skip to content
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

optimisations for master_me 2.0 #93

Open
trummerschlunk opened this issue Oct 10, 2022 · 5 comments
Open

optimisations for master_me 2.0 #93

trummerschlunk opened this issue Oct 10, 2022 · 5 comments

Comments

@trummerschlunk
Copy link
Owner

Hi everyone,

hope you are doing fine. I recovered a bit from the last months of master_me ;) Meanwhile, I used it on several projects and I am very happy with the sound, the dsp design, the gui... Great work y'all!

The resonance on mastodon was quite impressive. People seem to want this :) And we did not even post on birdsite & co yet... https://chaos.social/web/@trummerschlunk/108927371163970570

On my M1 macbook pro, several instances run smoothly, but I guess, master_me needs a round of optimization regarding cpu usage - so I want to start this thread.

  1. On the FAUST side
    Any ideas on how to make things more efficient here?

  2. On the C++ side
    Can some parts, or even modules (like lufs metering) be coded more efficiently, using pure C++ code (from other open-source projects)?
    How much potential lies in this approach at all?

  3. On the GUI side
    How about communication between FAUST generated code and GUI? Some issues are already discussed here: very high cpu usage #66

Thank you for your contributions and ongoing support <3

Klaus

@sletz
Copy link

sletz commented Oct 10, 2022

I guess most of the CPU goes inside the DSP loop itself, because it contains a lot of code... I cannot comment too much on the Faust DSP code itself (not enough understanding of the implementation) but by following the Optimizing the code and Debugging the Code pages here:

  • using the FIR backend to gets some statistics: Instructions complexity : Load = 6025 Store = 1037 Binop = 4136 [ { Int(&) = 108 } { Int(*) = 4 } { Int(+) = 25 } { Int(-) = 14 } { Int(<) = 3 } { Int(==) = 46 } { Int(>) = 16 } { Real(*) = 1727 } { Real(+) = 1214 } { Real(-) = 536 } { Real(/) = 363 } { Real(<) = 5 } { Real(>) = 75 } ] Mathop = 363 [ { expf = 1 } { fabsf = 37 } { log10f = 30 } { logf = 3 } { max_f = 116 } { max_i = 2 } { min_f = 35 } { mydsp_faustpower2_f = 65 } { powf = 38 } { sqrtf = 36 } ] Numbers = 2127 Declare = 1377 Cast = 42 Select = 202 Loop = 15
    so a lot of math operations of each sample (and powf, sqrtf, log10f...etc...). Using some fast-math versions of them could help maybe, using the -fm <file> --fast-math <file> use optimized versions of mathematical functions implemented in <file>, use 'faust/dsp/fastmath.cpp' when file is 'def'. compilation option to replace the standard math ?
  • I suggest looking at faust2object also

@falkTX
Copy link
Collaborator

falkTX commented Oct 10, 2022

  • Using some fast-math versions of them could help maybe, using the -fm <file> --fast-math <file> use optimized versions of mathematical functions implemented in <file>, use 'faust/dsp/fastmath.cpp' when file is 'def'. compilation option to replace the standard math ?

I tried this already, and results are unusable.
Hard to tell exactly what breaks, we would need to split out the different blocks of processing and test 1 by 1. Can faust partially use the fastmath file for some code blocks while having the regular stuff on the rest?

@sletz
Copy link

sletz commented Oct 10, 2022

  • Using some fast-math versions of them could help maybe, using the -fm <file> --fast-math <file> use optimized versions of mathematical functions implemented in <file>, use 'faust/dsp/fastmath.cpp' when file is 'def'. compilation option to replace the standard math ?

I tried this already, and results are unusable. Hard to tell exactly what breaks, we would need to split out the different blocks of processing and test 1 by 1. Can faust partially use the fastmath file for some code blocks while having the regular stuff on the rest?

Not really, -fm is global for the entire DSP.

@falkTX
Copy link
Collaborator

falkTX commented Jan 2, 2023

Did some quick tests here, disabling individual modules and seeing what would happen to the CPU load.
Can say with 100% confidence that mscomp_bp is the heavy block on the whole chain.
I have a little embed PC that is able to run master_me with everything enabled except mscomp_bp. Once I enable that the CPU goes way too high.
More specifically, it is the B_band_Compressor_N_chan function that takes the most CPU.

If we can optimize that, the CPU usage of the plugin will become much more reasonable.

@trummerschlunk
Copy link
Owner Author

Thank you, @falkTX for testing!
@magnetophon and @x42... Any ideas?
I'll check the code too and see if I can find cheaper solutions.
Happy 23 y'all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants