spicy icon indicating copy to clipboard operation
spicy copied to clipboard

Avoid copy of data for UDP parsers

Open awelzel opened this issue 7 months ago • 1 comments

Chatting with @rsmmr , one idea came up to prevent copying data for UDP/block analyzers:

https://github.com/zeek/spicy/blob/26b3b791e3f9b34258e2b9494e17d5aaa70e7120/spicy/runtime/src/driver.cc#L259-L281

If any iterators into the stream are invalidated after parse1, seems the stream would not necessarily need to own the data.

This might improve performance for the spicy-quic analyzer when crunching through large transfers.

Relates to #1644

awelzel avatar Jan 23 '24 11:01 awelzel

My takeaway from #1644 was that introducing a non-owning Chunk introduces new overhead even in code not making use of it since it partially undos (the spirit of) the optimizations done in #1607, so we probably wouldn't want to use this approach here.

Since here the Stream is always fully consumed we could instead introduce a non-owning Stream for this problem. The naive zeroth implementation could just be a non-owning class derived from Stream which stores a string_view into the data; that would still incur the overhead of creating the base Stream, but might already bring sufficient perf improvements.

bbannier avatar Jan 23 '24 12:01 bbannier