trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shinr...@apache.org
Subject [trafficserver] branch master updated: TS-5095: IOBufferReader::read_avail adds to CPU utilization
Date Wed, 04 Jan 2017 14:26:29 GMT
This is an automated email from the ASF dual-hosted git repository.

shinrich pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  2c73240   TS-5095: IOBufferReader::read_avail adds to CPU utilization
2c73240 is described below

commit 2c732409176950634249b2203abb446468c07569
Author: Susan Hinrichs <shinrich@ieee.org>
AuthorDate: Tue Dec 13 23:46:04 2016 +0000

    TS-5095: IOBufferReader::read_avail adds to CPU utilization
---
 iocore/eventsystem/IOBuffer.cc  | 13 +++++++------
 iocore/eventsystem/P_IOBuffer.h |  2 --
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/iocore/eventsystem/IOBuffer.cc b/iocore/eventsystem/IOBuffer.cc
index c7a2b78..c1c11d7 100644
--- a/iocore/eventsystem/IOBuffer.cc
+++ b/iocore/eventsystem/IOBuffer.cc
@@ -188,19 +188,20 @@ MIOBuffer::puts(char *s, int64_t len)
 int64_t
 IOBufferReader::read(void *ab, int64_t len)
 {
-  char *b           = (char *)ab;
-  int64_t max_bytes = read_avail();
-  int64_t bytes     = len <= max_bytes ? len : max_bytes;
-  int64_t n         = bytes;
+  char *b       = (char *)ab;
+  int64_t n     = len;
+  int64_t l     = block_read_avail();
+  int64_t bytes = 0;
 
-  while (n) {
-    int64_t l = block_read_avail();
+  while (n && l) {
     if (n < l)
       l = n;
     ::memcpy(b, start(), l);
     consume(l);
     b += l;
     n -= l;
+    bytes += l;
+    l = block_read_avail();
   }
   return bytes;
 }
diff --git a/iocore/eventsystem/P_IOBuffer.h b/iocore/eventsystem/P_IOBuffer.h
index 722b32f..64fb6fb 100644
--- a/iocore/eventsystem/P_IOBuffer.h
+++ b/iocore/eventsystem/P_IOBuffer.h
@@ -678,8 +678,6 @@ IOBufferReader::consume(int64_t n)
     block        = block->next;
     r            = block->read_avail();
   }
-
-  ink_assert(read_avail() >= 0);
 }
 
 TS_INLINE char &IOBufferReader::operator[](int64_t i)

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

Mime
View raw message