3 ms·
>do not use lookup tables, they unnecessarily fill the cache, cpus are fast enough Whoa, slow down. Testing will tell you which one is faster, but if you're ap
by pierrec 10y ago
>do not use lookup tables, they unnecessarily fill the cache, cpus are fast enough
Whoa, slow down. Testing will tell you which one is faster, but if you're applying a complicated function to every sample (eg. one that uses pow, log or trig especially more than once), lookup tables are definitely to be considered. The more complex the function, the more of a performance gain it will represent. An arithmetic approximation such as Chebyshev approximation can also work, but may or may not be more efficient depending on the function.
And yes, make sure you optimize the size of your table to be as small as possible while maintaining acceptable quality (which also depends on the interpolation you're using to access it). Everything is a tradeoff. New processors are efficient but not magical, and I've seen a marked performance improvement after applying a lookup table on a small plugin a few months ago, all of this on a very modern i7.
- iammyIP 10y agoYou should not use standard pow and log but approximations of these functions. These are usually faster than any lookup table that fills a good part of the cache and then you stall. But there might be some gray area, depending on the system. Or when full precision is needed. In most audio cases approximations work very well. Atleast that was what my testing showed. edit: it might be different for a single plugin, where there isn't much need for cache, but as the core loop grows bigger, you also need the cache more.
- Razengan 10y ago> Whoa, slow down. An unfortunate suggestion, given the context. :) GP and others always mention using C/C++, but what about Rust? Is it viable [enough] for these kind of problems? For high-performance code in game engines etc.? Edit: Ah I should've searched: https://news.ycombinator.com/item?id=11908849 https://news.ycombinator.com/item?id=11908849
- vvanders 10y agoRust would be fine, biggest hurdle is getting all the various libraries that C/C++ already has access too. I was looking into audio modem stuff a while back for APRS and it seems like most of the linux audio libraries already have Rust equivalent wrappers.