-
Notifications
You must be signed in to change notification settings - Fork 25
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
No memmove #36
base: master
Are you sure you want to change the base?
No memmove #36
Conversation
Win7 x86
|
it looks okay to me, though the complexity of the circular buffer has increased quite a bit and I didn't really try to think through every possible corner case. Is the memmove really a big enough performance concern to justify the increase in complexity? |
This allows to avoid memmove after each consume_cbuff_data. Some extra care was necessary to round queue transactions to a multiple of the sample size. I also did some refactoring on the cbuff to allow it to grow and on the resamplers to allw them to report not only how many bytes were consumed, but also how many bytes were produced, so we can move cbuff pointers accordingly. tail/head methods reports the available sizes in 2 parameters : "available" for the first chunk size, and "extra" for the optional second chunk (which starts at the buffer beginning). It's up to the caller to split it's contiguous accesses around these two chunks. Another method that I initially wanted to try was the virtual memory trick to mirror the beggining of the buffer at the end of itself. But this trick requires some code specific platform and can be tricky when we need to grow the buffer. So I went this explicit 2 chunk approach which is simpler and doesn't require platform specific code.
1c76454
to
f0ac812
Compare
@richard42 It's a fair point about complexity/performance. And I didn't really measure the performance of my changes, just thought about the theoretical benefits (and didn't observe any obvious change in my testings). That's why I asked if it helps for lower-end machines. Any how, I've rebased my changes, so it's easier to see what has changed. I don't mind if this PR doesn't make it because of added complexity vs performance increase, I proposed it mostly because I could. |
This PR is based on #35 (but might be rebasable on master if needed).
The intent was to avoid the "memmove" operation during each consume_cbuff_data call.
Now we expose the fact that the buffer might be split in 2 chunks and it's up to the caller to plan accordingly.
Some care has been taken to round accesses to a multiple of the sample size (a sample cannot be splitted between the 2 buffer chunks).
I'd like some feedback on low-end systems to see if that helps a bit with performance.