slaclab / pysmurf

Other
2 stars 9 forks source link

Fix drop frames to the external transmitters devices #647

Closed jesusvasquez333 closed 3 years ago

jesusvasquez333 commented 3 years ago

NOTE: This PR fixes the bad PR https://github.com/slaclab/pysmurf/pull/641 which was reverted as it included changes from the develop branch.

Issue

This PR resolves ESCRYODET-813.

Description

This PR fixes the bug reported by SO user in https://github.com/simonsobs/smurf-issues/issues/31.

Using the pysmurf-custom-transmitter-example I was able to reproduce the dropped frames on the transmitter.

The issue was due to a bug in the DualDataBuffer class which has incorrectly using a lock + conditional variable mechanism, and not protecting the shared variable. Moreover, the presence of that dual buffer was preventing the upstream 100-sample Fifo to do its job. So, I remove completely the DualDataBuffer from the data path and left only the Fifo. I also added an additional 100-sample Fifo to the meta-data path as well, which didn't have any buffer.

Additionally to that fix, I also extended the SmurfPacket class and added a version which doesn't copy the data from the underlaying frame into std::vectors, and instead just reference the values directly from the frames. This improves the performance when passing the data to an external transmitter device. The previous behavior of SmurfPacket is still available, and they can be selected using policy classes; but I set the default to be the zero copy version. This change will be transparent to the user.

Another optimization was to instantiated the FIFOs only when an external transmitter class is defined. Otherwise, the FIFO are not needed, and therefore not instantiated.

In order to have more debug information in the future about drop frames (if any) I added extra variable to the rogue tree:

I also found and fixed a couple of additional bug:

Finally, I added a new test script validate_base_tx.py to validate the correct functionality of the base transmitter module. I added this script to CI scripts.

And, of course, the documentation was updated.

Does this PR break any interface?

Which interface changed?

Although no interface was broken, this PR adds new variables with more debug information, as described above.