From 51ce03e76a1b848e97cb37ac8ae789de8318f8df Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 27 Aug 2018 22:55:19 +0200 Subject: [PATCH] stream/segments: speed up inserts Don't try to do a 'fast path' by checking RB_MAX. RB_MAX walks the tree which means it can be quite expensive. This cost would be paid for virtually every data segment. The actual insert that follows would walk the tree again. Instead, simply insert it. There is a slight cost of the unnecessary overlap check, but this is much less than the tree walk in a full tree. --- src/stream-tcp-list.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index 49e3c49e46..3c168de178 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -178,16 +178,6 @@ static int DoInsertSegment (TcpStream *stream, TcpSegment *seg, TcpSegment **dup return 0; } - /* insert the segment in the stream tree using this fast track, if seg->seq - is equal or higher than last segments tail. */ - TcpSegment *last = RB_MAX(TCPSEG, &stream->seg_tree); - if (last && SEQ_GEQ(seg->seq, (uint32_t)SEG_SEQ_RIGHT_EDGE(last))) - { - SCLogDebug("seg beyond tree tail, append"); - TCPSEG_RB_INSERT(&stream->seg_tree, seg); - return 0; - } - /* insert and then check if there was any overlap with other segments */ TcpSegment *res = TCPSEG_RB_INSERT(&stream->seg_tree, seg); if (res) {