-
Notifications
You must be signed in to change notification settings - Fork 53
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
Potential optimizations using System.Span, System.Memory, and stackalloc #22
Comments
Hello, sir. How can i help? Not really good at low-level stuff, but ready to try where I can |
Uh, yeah, sure. You can start with some of the tight-loop kernels such as in here. Replace the |
I took a quick shot of this because I was curious if .Net 6 carries an measurable performance benefits for this application. Porting the obvious places in kernels, xcorr, VQ, and NLSF yielded a slight (1-2%) benefit. Interestingly, when I ported over the MDCT code to use spans, the performance decreased by about 2%. My hunch is that the way that pointers get incremented in C (such as in kf_bfly5()) run faster when they are interpreted as incrementing the array index variables |
How ironic I was going to file this issue also as for c# this is no longer the case. Also I think Tanner Gooding knows of some intrinsics to increase perf on this as well. |
for VL stackalloc I would rather rent an |
Hey @lostromb , I noticed that library generates a LOT of garbage when decoding. Even for smallest chunk (10 ms), it allocates 37 KB of memory. I took a quick look at the code and spotted some obvious places where Span can be used instead of arrays. Also, Is there any plan to do this, or do you accept Pull Requests ? |
My current "plan" is to chip away at this branch and overhaul the entire code to use unsafe pointers and unmanaged allocation, which should run a lot faster, have better parity with the original code, make SIMD easier to implement, and have zero allocations. I just haven't had time to work on it for a bit. |
It's good to see that there is some progress. Plus, I am using this library on WebAssembly, so compatibility is also a concern for me. |
Concentus interpreted almost all C pointers as a combination of an array and an integer offset, e.g. "int[] x, int x_ptr". These could potentially all be replaced by new Span constructs in .NetCore 2.0 for better optimization. Furthermore, most stack array allocations are done on the heap in C#, which also yields bad performance (except where they were hand-inlined inside the FFT)
See https://msdn.microsoft.com/en-us/magazine/mt814808.aspx
The text was updated successfully, but these errors were encountered: