ejmahler / RustFFT

RustFFT is a high-performance FFT library written in pure Rust.
Apache License 2.0
705 stars 49 forks source link

Internal buffer #141

Closed daniellga closed 3 months ago

daniellga commented 3 months ago

This is just a question. Since all process_* methods for Fft use a scratch buffer, be it a user input or one created internally, why not to store this buffer internally on the structs, simplifying the number of methods needed for the trait (process_with_scratch would not be needed) and also assuring that every process_* use is reusing the same buffer as scratch?

HEnquist commented 3 months ago

This would mean that every process_* call modifies the FFT struct, which causes trouble if the FFT is used by several threads in parallel. Only way to solve that is by using a mutex to prevent parallel calls. The api gets easier but it doesn't seem like a good trade-off to me :)

daniellga commented 3 months ago

Can't an Arc be used in this case alongside its COW properties? If the scratch buffer is being used by another thread it would automatically just clone the buffer instead.

HEnquist commented 3 months ago

That would be better. But then you give up control over when allocations happen, which is probably not acceptable in many real time applications.

daniellga commented 3 months ago

Oh fair enough. Thanks for answering.