You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ok...@apache.org on 2017/10/28 01:33:56 UTC

[trafficserver] branch master updated: Optimize: define UDPQueue::atomicQueue by ASLL macro and rename to outQueue

This is an automated email from the ASF dual-hosted git repository.

oknet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new e920894  Optimize: define UDPQueue::atomicQueue by ASLL macro and rename to outQueue
e920894 is described below

commit e9208947a483dd543f06945167168c85ed3de35a
Author: Oknet Xu <xu...@skyguard.com.cn>
AuthorDate: Fri Oct 27 16:31:09 2017 +0800

    Optimize: define UDPQueue::atomicQueue by ASLL macro and rename to outQueue
---
 iocore/net/P_UDPNet.h    |  4 ++--
 iocore/net/UnixUDPNet.cc | 55 ++++++++++++++++++++----------------------------
 2 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h
index a093bb8..f2f8c0f 100644
--- a/iocore/net/P_UDPNet.h
+++ b/iocore/net/P_UDPNet.h
@@ -286,7 +286,8 @@ class UDPQueue
   int added               = 0;
 
 public:
-  InkAtomicList atomicQueue{};
+  // Outgoing UDP Packet Queue
+  ASLL(UDPPacketInternal, alink) outQueue;
 
   void service(UDPNetHandler *);
 
@@ -309,7 +310,6 @@ public:
   // to be called back with data
   Que(UnixUDPConnection, callback_link) udp_callbacks;
   // outgoing packets
-  InkAtomicList udpAtomicQueue{};
   UDPQueue udpOutQueue{};
   // to hold the newly created descriptors before scheduling them on
   // the servicing buckets.
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index fdd4076..008eafc 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -652,39 +652,31 @@ UDPQueue::service(UDPNetHandler *nh)
   ink_hrtime now     = Thread::get_hrtime_updated();
   uint64_t timeSpent = 0;
   uint64_t pktSendStartTime;
-  UDPPacketInternal *p;
   ink_hrtime pktSendTime;
-
-  p = (UDPPacketInternal *)ink_atomiclist_popall(&atomicQueue);
-  if (p) {
-    UDPPacketInternal *pnext = nullptr;
-    Queue<UDPPacketInternal> stk;
-
-    while (p) {
-      pnext         = p->alink.next;
-      p->alink.next = nullptr;
-      stk.push(p);
-      p = pnext;
+  UDPPacketInternal *p = nullptr;
+
+  SList(UDPPacketInternal, alink) aq(outQueue.popall());
+  Queue<UDPPacketInternal> stk;
+  while ((p = aq.pop())) {
+    stk.push(p);
+  }
+
+  // walk backwards down list since this is actually an atomic stack.
+  while ((p = stk.pop())) {
+    ink_assert(p->link.prev == nullptr);
+    ink_assert(p->link.next == nullptr);
+    // insert into our queue.
+    Debug("udp-send", "Adding %p", p);
+    if (p->conn->lastPktStartTime == 0) {
+      pktSendStartTime = std::max(now, p->delivery_time);
+    } else {
+      pktSendTime      = p->delivery_time;
+      pktSendStartTime = std::max(std::max(now, pktSendTime), p->delivery_time);
     }
+    p->conn->lastPktStartTime = pktSendStartTime;
+    p->delivery_time          = pktSendStartTime;
 
-    // walk backwards down list since this is actually an atomic stack.
-    while (stk.head) {
-      p = stk.pop();
-      ink_assert(p->link.prev == nullptr);
-      ink_assert(p->link.next == nullptr);
-      // insert into our queue.
-      Debug("udp-send", "Adding %p", p);
-      if (p->conn->lastPktStartTime == 0) {
-        pktSendStartTime = std::max(now, p->delivery_time);
-      } else {
-        pktSendTime      = p->delivery_time;
-        pktSendStartTime = std::max(std::max(now, pktSendTime), p->delivery_time);
-      }
-      p->conn->lastPktStartTime = pktSendStartTime;
-      p->delivery_time          = pktSendStartTime;
-
-      pipeInfo.addPacket(p, now);
-    }
+    pipeInfo.addPacket(p, now);
   }
 
   pipeInfo.advanceNow(now);
@@ -808,7 +800,7 @@ void
 UDPQueue::send(UDPPacket *p)
 {
   // XXX: maybe fastpath for immediate send?
-  ink_atomiclist_push(&atomicQueue, p);
+  outQueue.push((UDPPacketInternal *)p);
 }
 
 #undef LINK
@@ -816,7 +808,6 @@ UDPQueue::send(UDPPacket *p)
 UDPNetHandler::UDPNetHandler()
 {
   mutex = new_ProxyMutex();
-  ink_atomiclist_init(&udpOutQueue.atomicQueue, "Outgoing UDP Packet queue", offsetof(UDPPacketInternal, alink.next));
   ink_atomiclist_init(&udpNewConnections, "UDP Connection queue", offsetof(UnixUDPConnection, newconn_alink.next));
   nextCheck = Thread::get_hrtime_updated() + HRTIME_MSECONDS(1000);
   lastCheck = 0;

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].