gnuradio / pmt

pmt
GNU Lesser General Public License v3.0
11 stars 11 forks source link

Pmt vector double copy #18

Closed jsallay closed 2 years ago

jsallay commented 2 years ago

Pmt vectors (and other pmts for that matter) are initialized by creating a flatbuffer and then copying the contents or another array or pmt in. This frequently results in an extra copy of data, which should be avoidable. (For example, we deserialize so that we can figure out what type of data we have (doing a copy) and then we copy the data into a new pmt vector (doing another copy). We should investigate move constructors to make it more efficient.

jsallay commented 2 years ago

I dug in and did some investigation. Fixing this is going to require several changes to the pmt_base class. In particular in the serialize function, we take in a FlatBufferBuilder and process that. We cannot recreate a builder from a serialized buffer (as far as I can tell) in the deserialize function. This means that right now, we must create a new builder and then copy in the data.

I believe that we can store the data in serialized form at all times and just work with the buffers. I think this will have the side effect of making the pmt_base class much simpler as well.

jsallay commented 2 years ago

Fixed by https://github.com/gnuradio/pmt/pull/23