BatchDrake / sigutils

Small signal processing utility library
https://batchdrake.github.io/sigutils
GNU General Public License v3.0
71 stars 29 forks source link

Add support for zero-copy operations #85

Closed BatchDrake closed 6 months ago

BatchDrake commented 8 months ago

This comes from how Suscan delivers data to the channelizer. There is some potential bottleneck for high-rate signal sources, in which whatever is read from the source is copied back to a private buffer in both the channelizer and the smoothpsd. This can be improved by using zero-copy buffers, which should enable the following algorithm:

  1. Create certain object named sample_buffer_pool, with two atomic operations, acquire() and give(). acquire() must wait if too many buffers have been allocated. Perhaps use message pools?
  2. Give the possibility to add virtual circularity by means of mmap(), if the underlying architecture supports it.
  3. In the source worker, acquire a buffer by means of acquire() and populate it.
  4. Once the buffer is fully populated, apply the baseband filters, the smoothpsd, etc in the source worker
  5. Deliver the filtered buffer to the inspector worker and repeat from 1. This is actually an ownership transfer to the inspector worker.
  6. Remove the infamous inspsched barrier

In the inspector worker:

  1. The callback has ownership on the inspector worker. Deliver it to a new channelizer method, which will FFT it directly. If halfsize is lesser than PAGE_SIZE, copy last third. If halfsize is greater or equal than PAGE_SIZE and the architecture supports it, rely on virtual circularity. If the FFT buffer does not match the channelizer buffer, that is a bug
  2. Feed the inspectors accordingly.
  3. Release the buffer.

Requirements of sample_buffer_pool

BatchDrake commented 6 months ago

Implemented in Suscan, as it leverages the suscan_mq API