You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2019/04/24 04:02:27 UTC

[trafficserver] branch master updated: Removes priorities for AIOs, thanks oknet

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

bcall 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 e439818  Removes priorities for AIOs, thanks oknet
e439818 is described below

commit e4398187f1e058f7d45a0923769aa9cb6e140982
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Tue Apr 23 10:32:32 2019 +0800

    Removes priorities for AIOs, thanks oknet
    
    It also renames the http_aio_todo queue to just aio_todo. This
    was all dead code, that could not be triggered.
---
 include/tscore/ink_aiocb.h     | 11 +++--------
 iocore/aio/AIO.cc              | 42 +++++++++---------------------------------
 iocore/aio/I_AIO.h             |  4 ----
 iocore/aio/P_AIO.h             | 15 +++++----------
 iocore/cache/Cache.cc          | 14 --------------
 iocore/cache/CacheDisk.cc      |  7 +++----
 iocore/cache/I_Cache.h         | 10 ++++------
 iocore/cache/P_CacheInternal.h |  7 ++-----
 8 files changed, 26 insertions(+), 84 deletions(-)

diff --git a/include/tscore/ink_aiocb.h b/include/tscore/ink_aiocb.h
index ac50fbd..3a7b30e 100644
--- a/include/tscore/ink_aiocb.h
+++ b/include/tscore/ink_aiocb.h
@@ -46,14 +46,9 @@ struct ink_aiocb {
   void *aio_buf; /* buffer location */
 #endif
   size_t aio_nbytes; /* length of transfer */
+  off_t aio_offset;  /* file offset */
 
-  // TODO change to off_t
-  off_t aio_offset; /* file offset */
-
-  int aio_reqprio; /* request priority offset */
-  //    struct sigevent aio_sigevent;   /* signal number and offset */
   int aio_lio_opcode; /* listio operation */
-  //    aio_result_t    aio_resultp;    /* results */
-  int aio_state;   /* state flag for List I/O */
-  int aio__pad[1]; /* extension padding */
+  int aio_state;      /* state flag for List I/O */
+  int aio__pad[1];    /* extension padding */
 };
diff --git a/iocore/aio/AIO.cc b/iocore/aio/AIO.cc
index 29deaf6..e908542 100644
--- a/iocore/aio/AIO.cc
+++ b/iocore/aio/AIO.cc
@@ -206,16 +206,12 @@ struct AIOThreadInfo : public Continuation {
   }
 };
 
-/* priority scheduling */
-/* Have 2 queues per file descriptor - A queue for http requests and another
-   for non-http (streaming) request. Each file descriptor has a lock
-   and condition variable associated with it. A dedicated number of threads
-   (THREADS_PER_DISK) wait on the condition variable associated with the
-   file descriptor. The cache threads try to put the request in the
-   appropriate queue. If they fail to acquire the lock, they put the
-   request in the atomic list. Requests are served in the order of
-   highest priority first. If both the queues are empty, the aio threads
-   check if there is any request on the other disks */
+/*
+  A dedicated number of threads (THREADS_PER_DISK) wait on the condition
+  variable associated with the file descriptor. The cache threads try to put
+  the request in the appropriate queue. If they fail to acquire the lock, they
+  put the request in the atomic list.
+ */
 
 /* insert  an entry for file descriptor fildes into aio_reqs */
 static AIO_Reqs *
@@ -268,8 +264,7 @@ aio_init_fildes(int fildes, int fromAPI = 0)
   return request;
 }
 
-/* insert a request into either aio_todo or http_todo queue. aio_todo
-   list is kept sorted */
+/* insert a request into aio_todo queue. */
 static void
 aio_insert(AIOCallback *op, AIO_Reqs *req)
 {
@@ -277,22 +272,7 @@ aio_insert(AIOCallback *op, AIO_Reqs *req)
   num_requests++;
   req->queued++;
 #endif
-  if (op->aiocb.aio_reqprio == AIO_LOWEST_PRIORITY) // http request
-  {
-    req->http_aio_todo.enqueue(op);
-  } else {
-    AIOCallback *cb = (AIOCallback *)req->aio_todo.tail;
-
-    for (; cb; cb = (AIOCallback *)cb->link.prev) {
-      if (cb->aiocb.aio_reqprio >= op->aiocb.aio_reqprio) {
-        req->aio_todo.insert(op, cb);
-        return;
-      }
-    }
-
-    /* Either the queue was empty or this request has the highest priority */
-    req->aio_todo.push(op);
-  }
+  req->aio_todo.enqueue(op);
 }
 
 /* move the request from the atomic list to the queue */
@@ -466,7 +446,7 @@ aio_thread_main(void *arg)
       current_req = my_aio_req;
       /* check if any pending requests on the atomic list */
       aio_move(my_aio_req);
-      if (!(op = my_aio_req->aio_todo.pop()) && !(op = my_aio_req->http_aio_todo.pop())) {
+      if (!(op = my_aio_req->aio_todo.pop())) {
         break;
       }
 #ifdef AIO_STATS
@@ -578,7 +558,6 @@ Lagain:
 int
 ink_aio_read(AIOCallback *op, int /* fromAPI ATS_UNUSED */)
 {
-  op->aiocb.aio_reqprio    = AIO_DEFAULT_PRIORITY;
   op->aiocb.aio_lio_opcode = IO_CMD_PREAD;
   op->aiocb.data           = op;
   EThread *t               = this_ethread();
@@ -593,7 +572,6 @@ ink_aio_read(AIOCallback *op, int /* fromAPI ATS_UNUSED */)
 int
 ink_aio_write(AIOCallback *op, int /* fromAPI ATS_UNUSED */)
 {
-  op->aiocb.aio_reqprio    = AIO_DEFAULT_PRIORITY;
   op->aiocb.aio_lio_opcode = IO_CMD_PWRITE;
   op->aiocb.data           = op;
   EThread *t               = this_ethread();
@@ -614,7 +592,6 @@ ink_aio_readv(AIOCallback *op, int /* fromAPI ATS_UNUSED */)
   int sz          = 0;
 
   while (io) {
-    io->aiocb.aio_reqprio    = AIO_DEFAULT_PRIORITY;
     io->aiocb.aio_lio_opcode = IO_CMD_PREAD;
     io->aiocb.data           = io;
 #ifdef HAVE_EVENTFD
@@ -645,7 +622,6 @@ ink_aio_writev(AIOCallback *op, int /* fromAPI ATS_UNUSED */)
   int sz          = 0;
 
   while (io) {
-    io->aiocb.aio_reqprio    = AIO_DEFAULT_PRIORITY;
     io->aiocb.aio_lio_opcode = IO_CMD_PWRITE;
     io->aiocb.data           = io;
 #ifdef HAVE_EVENTFD
diff --git a/iocore/aio/I_AIO.h b/iocore/aio/I_AIO.h
index 6b957b6..8618e59 100644
--- a/iocore/aio/I_AIO.h
+++ b/iocore/aio/I_AIO.h
@@ -72,7 +72,6 @@ struct ink_aiocb {
   size_t aio_nbytes = 0;       /* length of transfer */
   off_t aio_offset  = 0;       /* file offset */
 
-  int aio_reqprio    = 0; /* request priority offset */
   int aio_lio_opcode = 0; /* listio operation */
   int aio_state      = 0; /* state flag for List I/O */
   int aio__pad[1];        /* extension padding */
@@ -86,9 +85,6 @@ bool ink_aio_thread_num_set(int thread_num);
 #define AIO_CALLBACK_THREAD_ANY ((EThread *)0) // any regular event thread
 #define AIO_CALLBACK_THREAD_AIO ((EThread *)-1)
 
-#define AIO_LOWEST_PRIORITY 0
-#define AIO_DEFAULT_PRIORITY AIO_LOWEST_PRIORITY
-
 struct AIOCallback : public Continuation {
   // set before calling aio_read/aio_write
   ink_aiocb aiocb;
diff --git a/iocore/aio/P_AIO.h b/iocore/aio/P_AIO.h
index 06eb15b..95534c9 100644
--- a/iocore/aio/P_AIO.h
+++ b/iocore/aio/P_AIO.h
@@ -85,24 +85,19 @@ struct AIOCallbackInternal : public AIOCallback {
 
   int io_complete(int event, void *data);
 
-  AIOCallbackInternal()
-  {
-    aiocb.aio_reqprio = AIO_DEFAULT_PRIORITY;
-    SET_HANDLER(&AIOCallbackInternal::io_complete);
-  }
+  AIOCallbackInternal() { SET_HANDLER(&AIOCallbackInternal::io_complete); }
 };
 
 struct AIO_Reqs {
-  Que(AIOCallback, link) aio_todo;      /* queue for holding non-http requests */
-  Que(AIOCallback, link) http_aio_todo; /* queue for http requests */
-                                        /* Atomic list to temporarily hold the request if the
-                                           lock for a particular queue cannot be acquired */
+  Que(AIOCallback, link) aio_todo; /* queue for AIO operations */
+                                   /* Atomic list to temporarily hold the request if the
+                                      lock for a particular queue cannot be acquired */
   ASLL(AIOCallbackInternal, alink) aio_temp_list;
   ink_mutex aio_mutex;
   ink_cond aio_cond;
   int index           = 0; /* position of this struct in the aio_reqs array */
   int pending         = 0; /* number of outstanding requests on the disk */
-  int queued          = 0; /* total number of aio_todo and http_todo requests */
+  int queued          = 0; /* total number of aio_todo requests */
   int filedes         = 0; /* the file descriptor for the requests */
   int requests_queued = 0;
 };
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index 9d98607..8b6ab8d 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -482,14 +482,6 @@ CacheVC::set_pin_in_cache(time_t time_pin)
   return true;
 }
 
-bool
-CacheVC::set_disk_io_priority(int priority)
-{
-  ink_assert(priority >= AIO_LOWEST_PRIORITY);
-  io.aiocb.aio_reqprio = priority;
-  return true;
-}
-
 time_t
 CacheVC::get_pin_in_cache()
 {
@@ -497,12 +489,6 @@ CacheVC::get_pin_in_cache()
 }
 
 int
-CacheVC::get_disk_io_priority()
-{
-  return io.aiocb.aio_reqprio;
-}
-
-int
 Vol::begin_read(CacheVC *cont)
 {
   ink_assert(cont->mutex->thread_holding == this_ethread());
diff --git a/iocore/cache/CacheDisk.cc b/iocore/cache/CacheDisk.cc
index 78beffe..8e98e30 100644
--- a/iocore/cache/CacheDisk.cc
+++ b/iocore/cache/CacheDisk.cc
@@ -61,10 +61,9 @@ CacheDisk::open(char *s, off_t blocks, off_t askip, int ahw_sector_size, int fil
   skip           = askip;
   start          = skip;
   /* we can't use fractions of store blocks. */
-  len                  = blocks;
-  io.aiocb.aio_fildes  = fd;
-  io.aiocb.aio_reqprio = 0;
-  io.action            = this;
+  len                 = blocks;
+  io.aiocb.aio_fildes = fd;
+  io.action           = this;
   // determine header size and hence start point by successive approximation
   uint64_t l;
   for (int i = 0; i < 3; i++) {
diff --git a/iocore/cache/I_Cache.h b/iocore/cache/I_Cache.h
index 8d4447b..b0fd544 100644
--- a/iocore/cache/I_Cache.h
+++ b/iocore/cache/I_Cache.h
@@ -189,12 +189,10 @@ struct CacheVConnection : public VConnection {
   virtual void set_http_info(CacheHTTPInfo *info)  = 0;
   virtual void get_http_info(CacheHTTPInfo **info) = 0;
 
-  virtual bool is_ram_cache_hit() const           = 0;
-  virtual bool set_disk_io_priority(int priority) = 0;
-  virtual int get_disk_io_priority()              = 0;
-  virtual bool set_pin_in_cache(time_t t)         = 0;
-  virtual time_t get_pin_in_cache()               = 0;
-  virtual int64_t get_object_size()               = 0;
+  virtual bool is_ram_cache_hit() const   = 0;
+  virtual bool set_pin_in_cache(time_t t) = 0;
+  virtual time_t get_pin_in_cache()       = 0;
+  virtual int64_t get_object_size()       = 0;
   virtual bool
   is_compressed_in_ram() const
   {
diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h
index 54d5314..7ba0e24 100644
--- a/iocore/cache/P_CacheInternal.h
+++ b/iocore/cache/P_CacheInternal.h
@@ -388,8 +388,6 @@ struct CacheVC : public CacheVConnection {
   bool is_pread_capable() override;
   bool set_pin_in_cache(time_t time_pin) override;
   time_t get_pin_in_cache() override;
-  bool set_disk_io_priority(int priority) override;
-  int get_disk_io_priority() override;
 
 // offsets from the base stat
 #define CACHE_STAT_ACTIVE 0
@@ -585,9 +583,8 @@ free_CacheVC(CacheVC *cont)
   cont->io.action.continuation = nullptr;
   cont->io.action.mutex        = nullptr;
   cont->io.mutex.clear();
-  cont->io.aio_result        = 0;
-  cont->io.aiocb.aio_nbytes  = 0;
-  cont->io.aiocb.aio_reqprio = AIO_DEFAULT_PRIORITY;
+  cont->io.aio_result       = 0;
+  cont->io.aiocb.aio_nbytes = 0;
   cont->request.reset();
   cont->vector.clear();
   cont->vio.buffer.clear();