Repository navigation
Use Two-Way for finding the delimiter in DelimiterBasedFrameDecoder - #13451
Conversation
Motivation: We were using the naive and inefficient O(nm) algorithm here. Modification: Remove the naive algorithm and instead call out to the optimised Two-Way search we already have in ByteBufUtil. Result: The DelimiterBasedFrameDecoder now searches for delimiters using the fastest algorithm available to us. Fixes netty#13313
|
I suspect single-byte delimiters are fairly common, e.g. a single newline character. |
|
Nice, so let's wait the user feedback... |
|
Just some before I forgot about them... In the case of multi bytes delimiters, this should further increase performance for such a frequent op |
|
Nice one @chrisvest |
|
@chrisvest can you also port this to main if needed ? |
…13451) Motivation: We were using the naive and inefficient O(nm) algorithm here. Modification: Remove the naive algorithm and instead call out to the optimised Two-Way search we already have in ByteBufUtil. Result: The DelimiterBasedFrameDecoder now searches for delimiters using the fastest algorithm available to us. Fixes #13313
|
For what it's worth, downstream we have ended up doing https://git.opendaylight.org/gerrit/c/netconf/+/101892/1/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/NetconfEOMAggregator.java The point is that the base class is not @sharable and therefore has context. While the two-way is a nice optimization, I think remembering previously-checked ranges is more beneficial. Our use case entails relatively small message chunks (couple of KiB) being aggregated to large messages (10s of MiB). EOM marker is multi-byte in this case. |
|
@rovarga we love PRs... If you have some ideas how to improve things just open a PR :) |

Motivation:
We were using the naive and inefficient O(nm) algorithm here.
Modification:
Remove the naive algorithm and instead call out to the optimised Two-Way search we already have in ByteBufUtil.
Result:
The DelimiterBasedFrameDecoder now searches for delimiters using the fastest algorithm available to us.
Fixes #13313