trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject svn commit: r1102889 - in /trafficserver/traffic/trunk: iocore/eventsystem/IOBuffer.cc iocore/hostdb/HostDB.cc iocore/net/UnixNetPages.cc lib/ts/ink_string++.cc lib/ts/ink_string++.h proxy/http/HttpTransact.h proxy/http/remap/RemapProcessor.cc
Date Fri, 13 May 2011 20:34:34 GMT
Author: zwoop
Date: Fri May 13 20:34:34 2011
New Revision: 1102889

URL: http://svn.apache.org/viewvc?rev=1102889&view=rev
Log:
TS-776 memchr in glibc has evolved, and is faster than our version, replace

Modified:
    trafficserver/traffic/trunk/iocore/eventsystem/IOBuffer.cc
    trafficserver/traffic/trunk/iocore/hostdb/HostDB.cc
    trafficserver/traffic/trunk/iocore/net/UnixNetPages.cc
    trafficserver/traffic/trunk/lib/ts/ink_string++.cc
    trafficserver/traffic/trunk/lib/ts/ink_string++.h
    trafficserver/traffic/trunk/proxy/http/HttpTransact.h
    trafficserver/traffic/trunk/proxy/http/remap/RemapProcessor.cc

Modified: trafficserver/traffic/trunk/iocore/eventsystem/IOBuffer.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/eventsystem/IOBuffer.cc?rev=1102889&r1=1102888&r2=1102889&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/eventsystem/IOBuffer.cc (original)
+++ trafficserver/traffic/trunk/iocore/eventsystem/IOBuffer.cc Fri May 13 20:34:34 2011
@@ -206,6 +206,7 @@ IOBufferReader::read(void *ab, int64_t l
   return bytes;
 }
 
+// TODO: I don't think this method is used anywhere, so perhaps get rid of it ?
 int64_t
 IOBufferReader::memchr(char c, int64_t len, int64_t offset)
 {
@@ -227,7 +228,7 @@ IOBufferReader::memchr(char c, int64_t l
     else
       bytes = len;
     char *s = b->start() + offset;
-    char *p = (char *) ink_memchr(s, c, bytes);
+    char *p = (char *) ::memchr(s, c, bytes);
     if (p)
       return (int64_t) (o - start_offset + p - s);
     o += bytes;

Modified: trafficserver/traffic/trunk/iocore/hostdb/HostDB.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/hostdb/HostDB.cc?rev=1102889&r1=1102888&r2=1102889&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/hostdb/HostDB.cc (original)
+++ trafficserver/traffic/trunk/iocore/hostdb/HostDB.cc Fri May 13 20:34:34 2011
@@ -197,10 +197,10 @@ struct HostDBTestRR: public Continuation
     while (outstanding < 40) {
       if (!nb)
         goto Lreturn;
-      char *end = (char *) ink_memchr(b, '\n', nb);
+      char *end = (char *)memchr(b, '\n', nb);
       if (!end)
         read_some();
-      end = (char *) ink_memchr(b, '\n', nb);
+      end = (char *)memchr(b, '\n', nb);
       if (!end)
         nb = 0;
       else {
@@ -2199,7 +2199,7 @@ register_ShowHostDB(Continuation * c, HT
     s->sarg = xstrndup(query, query_len);
     char *gn = NULL;
     if (s->sarg)
-      gn = (char *) ink_memchr(s->sarg, '=', strlen(s->sarg));
+      gn = (char *)memchr(s->sarg, '=', strlen(s->sarg));
     if (gn)
       s->ip = ink_inet_addr(gn + 1);
     SET_CONTINUATION_HANDLER(s, &ShowHostDB::showLookup);
@@ -2210,7 +2210,7 @@ register_ShowHostDB(Continuation * c, HT
     s->sarg = xstrndup(query, query_len);
     char *gn = NULL;
     if (s->sarg)
-      gn = (char *) ink_memchr(s->sarg, '=', strlen(s->sarg));
+      gn = (char *)memchr(s->sarg, '=', strlen(s->sarg));
     if (gn)
       s->name = gn + 1;
     SET_CONTINUATION_HANDLER(s, &ShowHostDB::showLookup);

Modified: trafficserver/traffic/trunk/iocore/net/UnixNetPages.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/net/UnixNetPages.cc?rev=1102889&r1=1102888&r2=1102889&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/net/UnixNetPages.cc (original)
+++ trafficserver/traffic/trunk/iocore/net/UnixNetPages.cc Fri May 13 20:34:34 2011
@@ -225,7 +225,7 @@ register_ShowNet(Continuation * c, HTTPH
     s->sarg = xstrndup(query, query_len);
     char *gn = NULL;
     if (s->sarg)
-      gn = (char *) ink_memchr(s->sarg, '=', strlen(s->sarg));
+      gn = (char *)memchr(s->sarg, '=', strlen(s->sarg));
     if (gn)
       s->ip = ink_inet_addr(gn + 1);
     SET_CONTINUATION_HANDLER(s, &ShowNet::showConnections);
@@ -235,7 +235,7 @@ register_ShowNet(Continuation * c, HTTPH
     s->sarg = xstrndup(query, query_len);
     char *gn = NULL;
     if (s->sarg)
-      gn = (char *) ink_memchr(s->sarg, '=', strlen(s->sarg));
+      gn = (char *)memchr(s->sarg, '=', strlen(s->sarg));
     if (gn)
       s->port = atoi(gn + 1);
     SET_CONTINUATION_HANDLER(s, &ShowNet::showConnections);

Modified: trafficserver/traffic/trunk/lib/ts/ink_string++.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_string%2B%2B.cc?rev=1102889&r1=1102888&r2=1102889&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_string++.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_string++.cc Fri May 13 20:34:34 2011
@@ -36,140 +36,6 @@
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
-void *
-ink_memchr(const void *as, int ac, size_t an)
-{
-  unsigned char c = (unsigned char) ac;
-  unsigned char *s = (unsigned char *) as;
-
-  // initial segment
-
-  int i_len = (int)(((uintptr_t) 8 - (uintptr_t) as) & 7);
-
-  // too short to concern us
-
-  if ((int) an < i_len) {
-    for (int i = 0; i < (int) an; i++)
-      if (s[i] == c)
-        return &s[i];
-    return 0;
-  }
-  // bytes 0-3
-
-  // Is this right?  I would think this should be (4 - i_len&3)...
-  switch (i_len & 3) {
-  case 3:
-    if (*s++ == c)
-      return s - 1;
-  case 2:
-    if (*s++ == c)
-      return s - 1;
-  case 1:
-    if (*s++ == c)
-      return s - 1;
-  case 0:
-    break;
-  }
-
-  // bytes 4-8
-
-  unsigned int ib = c;
-  ib |= (ib << 8);
-  ib |= (ib << 16);
-  unsigned int im = 0x7efefeff;
-  if (i_len & 4) {
-    unsigned int ibp = *(unsigned int *) s;
-    unsigned int ibb = ibp ^ ib;
-    ibb = ((ibb + im) ^ ~ibb) & ~im;
-    if (ibb) {
-      if (s[0] == c)
-        return &s[0];
-      if (s[1] == c)
-        return &s[1];
-      if (s[2] == c)
-        return &s[2];
-      if (s[3] == c)
-        return &s[3];
-    }
-    s += 4;
-  }
-  // next 8x bytes
-  uint64_t m = 0x7efefefefefefeffLL;
-  uint64_t b = ((uint64_t) ib);
-  b |= (b << 32);
-  uint64_t *p = (uint64_t *) s;
-  unsigned int n = (unsigned int) ((((unsigned int) an) - (s - (unsigned char *) as)) >>
3);
-  uint64_t *end = p + n;
-  while (p < end) {
-    uint64_t bp = *p;
-    uint64_t bb = bp ^ b;
-    bb = ((bb + m) ^ ~bb) & ~m;
-    if (bb) {
-      s = (unsigned char *) p;
-      if (s[0] == c)
-        return &s[0];
-      if (s[1] == c)
-        return &s[1];
-      if (s[2] == c)
-        return &s[2];
-      if (s[3] == c)
-        return &s[3];
-      if (s[4] == c)
-        return &s[4];
-      if (s[5] == c)
-        return &s[5];
-      if (s[6] == c)
-        return &s[6];
-      if (s[7] == c)
-        return &s[7];
-    }
-    p++;
-  }
-
-  // terminal segement
-
-  i_len = (int) (an - (((unsigned char *) p) - ((unsigned char *) as)));
-  s = (unsigned char *) p;
-
-  // n-(4..8)..n bytes
-
-  if (i_len & 4) {
-    unsigned int ibp = *(unsigned int *) s;
-    unsigned int ibb = ibp ^ ib;
-    ibb = ((ibb + im) ^ ~ibb) & ~im;
-    if (ibb) {
-      if (s[0] == c)
-        return &s[0];
-      if (s[1] == c)
-        return &s[1];
-      if (s[2] == c)
-        return &s[2];
-      if (s[3] == c)
-        return &s[3];
-    }
-    s += 4;
-  }
-  // n-(0..3)..n bytes
-
-  switch (i_len & 3) {
-  case 3:
-    if (*s++ == c)
-      return s - 1;
-  case 2:
-    if (*s++ == c)
-      return s - 1;
-  case 1:
-    if (*s++ == c)
-      return s - 1;
-  case 0:
-    break;
-  }
-  return 0;
-}
-
-/*-------------------------------------------------------------------------
-  -------------------------------------------------------------------------*/
-
 char *
 ink_memcpy_until_char(char *dst, char *src, unsigned int n, unsigned char c)
 {

Modified: trafficserver/traffic/trunk/lib/ts/ink_string++.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_string%2B%2B.h?rev=1102889&r1=1102888&r2=1102889&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_string++.h (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_string++.h Fri May 13 20:34:34 2011
@@ -64,8 +64,6 @@ _strlen(const char *src)
   return (int) (src - old_src);
 }
 
-void *ink_memchr(const void *as, int ac, size_t an);
-
 /***********************************************************************
  *                                                                     *
  *                     Str (string/length list cell)                   *

Modified: trafficserver/traffic/trunk/proxy/http/HttpTransact.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpTransact.h?rev=1102889&r1=1102888&r2=1102889&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpTransact.h (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpTransact.h Fri May 13 20:34:34 2011
@@ -1469,14 +1469,11 @@ is_response_body_precluded(HTTPStatus st
   }
 }
 
-inkcoreapi extern
-  ink_time_t
-ink_cluster_time(void);
+inkcoreapi extern ink_time_t ink_cluster_time(void);
 
 inline void
 HttpTransact::update_stat(State* s, int stat, ink_statval_t increment)
 {
-
   if (s->current_stats->next_insert >= StatBlockEntries) {
     // This a rare operation and we want to avoid the
     //   code bloat of inlining it everywhere so

Modified: trafficserver/traffic/trunk/proxy/http/remap/RemapProcessor.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/remap/RemapProcessor.cc?rev=1102889&r1=1102888&r2=1102889&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/remap/RemapProcessor.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/remap/RemapProcessor.cc Fri May 13 20:34:34 2011
@@ -107,6 +107,10 @@ RemapProcessor::setup_for_remap(HttpTran
       // we need to copy it. Perhaps it's because it's simpler to just
       // do the remap on the URL and then fix the field at the end.
       request_header->set_url_target_from_host_field();
+
+      // TODO: This is pretty slow, and only used for logging. Can we by chance avoid
+      // doing this is nothing is known to need it ? Perhaps the log library could
+      // have a table with status of what resources is necessary.
       *orig_url = request_url->string_get_ref(NULL);
     }
   }



Mime
View raw message