[haiku-commits] Change in haiku[master]: tcp: Remove sanity checks from BufferQueue in release builds

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 23 May 2020 02:30:30 +0000

From Kyle Ambroff-Kao <kyle@xxxxxxxxxxxxxx>:

Kyle Ambroff-Kao has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2781 ;)


Change subject: tcp: Remove sanity checks from BufferQueue in release builds
......................................................................

tcp: Remove sanity checks from BufferQueue in release builds

Each TCPEndpoint has two BufferQueue members, one for the send queue
and one for the receive queue.

If DEBUG_BUFFER_QUEUE is enabled, then most methods of BufferQueue
call BufferQueue::Verify(), sometimes twice. This member function
performs some sanity checking which requires iterating through every
net_buffer in the queue.

Disabling this in a debug build improved throughput by a factor of 5x
over the loopback interface on my laptop. Using iperf the measured
throughput went from 900Mbps to around 4.8Gbps.

This patch turns this sanity checking off for release builds.

* Rename DEBUG_BUFFER_QUEUE to DEBUG_TCP_BUFFER_QUEUE
* Change the default in BufferQueue.h to disabled
* Set DEBUG_TCP_BUFFER_QUEUE to KDEBUG_LEVEL_2 in
  kernel_debug_config.h
---
M build/config_headers/kernel_debug_config.h
M src/add-ons/kernel/network/protocols/tcp/BufferQueue.cpp
M src/add-ons/kernel/network/protocols/tcp/BufferQueue.h
M src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp
M src/tests/system/network/tcp_shell/BufferQueueTest.cpp
5 files changed, 13 insertions(+), 11 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/81/2781/1

diff --git a/build/config_headers/kernel_debug_config.h 
b/build/config_headers/kernel_debug_config.h
index 1dcc08f..2a0b4d6 100644
--- a/build/config_headers/kernel_debug_config.h
+++ b/build/config_headers/kernel_debug_config.h
@@ -140,4 +140,10 @@
 #define SYSTEM_PROFILE_INTERVAL                        10000


+// Network
+
+// Enables additional assertions in the tcp add-on.
+#define DEBUG_TCP_BUFFER_QUEUE                 KDEBUG_LEVEL_2
+
+
 #endif // KERNEL_DEBUG_CONFIG_H
diff --git a/src/add-ons/kernel/network/protocols/tcp/BufferQueue.cpp 
b/src/add-ons/kernel/network/protocols/tcp/BufferQueue.cpp
index de83ba3..4d5ada0 100644
--- a/src/add-ons/kernel/network/protocols/tcp/BufferQueue.cpp
+++ b/src/add-ons/kernel/network/protocols/tcp/BufferQueue.cpp
@@ -19,7 +19,7 @@
 #      define TRACE(x)
 #endif

-#if DEBUG_BUFFER_QUEUE
+#if DEBUG_TCP_BUFFER_QUEUE
 #      define VERIFY() Verify();
 #else
 #      define VERIFY() ;
@@ -436,7 +436,7 @@
                fPushPointer = fList.Tail()->sequence + fList.Tail()->size;
 }

-#if DEBUG_BUFFER_QUEUE
+#if DEBUG_TCP_BUFFER_QUEUE

 /*!    Perform a sanity check of the whole queue.
 */
@@ -486,4 +486,4 @@
        }
 }

-#endif // DEBUG_BUFFER_QUEUE
+#endif // DEBUG_TCP_BUFFER_QUEUE
diff --git a/src/add-ons/kernel/network/protocols/tcp/BufferQueue.h 
b/src/add-ons/kernel/network/protocols/tcp/BufferQueue.h
index 73986a8..f428ae9 100644
--- a/src/add-ons/kernel/network/protocols/tcp/BufferQueue.h
+++ b/src/add-ons/kernel/network/protocols/tcp/BufferQueue.h
@@ -13,10 +13,6 @@

 #include <util/DoublyLinkedList.h>

-#ifndef DEBUG_BUFFER_QUEUE
-#      define DEBUG_BUFFER_QUEUE 1
-#endif
-

 typedef DoublyLinkedList<struct net_buffer,
        DoublyLinkedListCLink<struct net_buffer> > SegmentList;
@@ -55,7 +51,7 @@
                        tcp_sequence            NextSequence() const
                                                                        { 
return fFirstSequence + fContiguousBytes; }

-#if DEBUG_BUFFER_QUEUE
+#if DEBUG_TCP_BUFFER_QUEUE
                        void                            Verify() const;
                        void                            Dump() const;
 #endif
diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 
b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp
index 9640f8b..0c4d9ca 100644
--- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp
+++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp
@@ -2533,7 +2533,7 @@
        kprintf("    max segment size: %" B_PRIu32 "\n", fSendMaxSegmentSize);
        kprintf("    queue: %" B_PRIuSIZE " / %" B_PRIuSIZE "\n", 
fSendQueue.Used(),
                fSendQueue.Size());
-#if DEBUG_BUFFER_QUEUE
+#if DEBUG_TCP_BUFFER_QUEUE
        fSendQueue.Dump();
 #endif
        kprintf("    last acknowledge sent: %" B_PRIu32 "\n",
@@ -2549,7 +2549,7 @@
        kprintf("    max segment size: %" B_PRIu32 "\n", 
fReceiveMaxSegmentSize);
        kprintf("    queue: %" B_PRIuSIZE " / %" B_PRIuSIZE "\n",
                fReceiveQueue.Available(), fReceiveQueue.Size());
-#if DEBUG_BUFFER_QUEUE
+#if DEBUG_TCP_BUFFER_QUEUE
        fReceiveQueue.Dump();
 #endif
        kprintf("    initial sequence: %" B_PRIu32 "\n",
diff --git a/src/tests/system/network/tcp_shell/BufferQueueTest.cpp 
b/src/tests/system/network/tcp_shell/BufferQueueTest.cpp
index ef8cbe0..ed54d35 100644
--- a/src/tests/system/network/tcp_shell/BufferQueueTest.cpp
+++ b/src/tests/system/network/tcp_shell/BufferQueueTest.cpp
@@ -3,7 +3,7 @@
  * Distributed under the terms of the MIT License.
  */

-#define DEBUG_BUFFER_QUEUE 1
+#define DEBUG_TCP_BUFFER_QUEUE 1

 #include "BufferQueue.h"


--
To view, visit https://review.haiku-os.org/c/haiku/+/2781
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: Idec01cffa4d7dc37eca46a5445756eb986508c35
Gerrit-Change-Number: 2781
Gerrit-PatchSet: 1
Gerrit-Owner: Kyle Ambroff-Kao <kyle@xxxxxxxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts: