36 Commits

Author SHA1 Message Date
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Markus Mäkelä
322983a5f4 Merge branch '2.1' into develop 2017-05-17 13:48:52 +03:00
Markus Mäkelä
dd8a10f466 Remove old polling message system
The old polling message system is obsolete now that the worker messages
are implemented. The old system was only used to clean up the persistent
connection pool of a server.
2017-05-03 14:16:35 +03:00
Johan Wikman
c5fd2bdb81 Add listening sockets to shared epoll instance
All sorts of additional cleaning up can now be performed.
2017-04-22 17:02:52 +03:00
Johan Wikman
db3153ee4e Move statistics to Worker
Now the statistics is in a single structure and the property of the
Worker instance in question. Methods are provided for obtaining the
statistics of all workers in one go.
2017-04-20 13:51:16 +03:00
Johan Wikman
722d6da46f The thread state is now a property of the worker
A worker's state is not statistics, but transient information.
2017-04-20 13:51:16 +03:00
Johan Wikman
effa2f5674 poll_waitevents moved to Worker
A direct move without any non-essential modifications. Poll_waitevents will
be turned into a regular methods using instance variables.
2017-04-20 13:51:16 +03:00
Johan Wikman
4ed615a6c1 Cleanup of poll.cc
Unnecessary/unused functions, variable and headers removed.
2017-04-20 13:51:16 +03:00
Johan Wikman
2bbb67b4f5 Remove old load calculation
The existing load calculation does not fit the 2.0 thread approach
that well. So it is removed entirely now, to be replaced with some
new approach later.
2017-04-20 13:51:16 +03:00
Johan Wikman
f742a98119 Remove queue event reporting
Was not updated, output meaningless.
2017-04-20 13:51:16 +03:00
Johan Wikman
b265ca457d Remove various obsolete stuff 2017-04-20 13:51:16 +03:00
Johan Wikman
3ac619bfec Fold thread state into poll stats 2017-04-20 13:51:16 +03:00
Johan Wikman
30d7f52852 Remove meaningsless stats
Showing dcb addresses, the number of fds and the events is
meaningless as the information is completely transient and
is likely to have changed the moment is was displayed.
2017-04-20 13:51:16 +03:00
Johan Wikman
1464230714 Fix stats calculation error 2017-04-20 13:51:16 +03:00
Johan Wikman
05d9d31499 Remove meaningless statistics
Counting how many times no threads are in epoll_wait does not
make sense anymore, now that threads do not share any work.
2017-04-20 13:51:16 +03:00
Johan Wikman
f952a11eb8 Move queue statistics to Worker
Just like the thread stats and poll stats earlier, the queue stats
are now moved to worker.

A litte refactoring still, and the polling will only work on local
data.
2017-04-20 13:51:16 +03:00
Johan Wikman
76825eb2c5 Poll statistics moved to worker
Each worker now has a separate structure for collecting the
polling statistics that is passed to epoll_waitevents(). When
the stats are asked for, we loop over all separate stats and
combine them. So, instead of having every statistics of each
thread one cacheline apart, each thread has all its statistics
in one lump that, for obvious reasons, are going to be apart.

The primary purpose of this excersize is to remove the hardwired
nature of the statistics collection. For instance, the admin
thread will be doing I/O but that I/O should not be included
in the statistics of the workers.
2017-04-20 13:51:16 +03:00
Johan Wikman
c11ca1c328 Move thread data to workers
This is a step in the direction that any worker/thread related data
is the property of the worker/thread.
2017-04-20 13:51:16 +03:00
Johan Wikman
d20c89be37 Use epoll instance of Worker
Now the epoll instance of the Worker is used when polling. The
work is still done in poll.cc and the worker provides the descriptor
and thread id.

The comments of poll_waitevents() have been removed; they were not
accurate anymore so better to let the code speak for itself.
2017-04-20 13:51:16 +03:00
Johan Wikman
949b41b0aa Remove serialization mutex from poll.cc
I don't think it has been ever used and the comment even suggested
that it "may" be useful.
2017-04-20 13:51:16 +03:00
Johan Wikman
21ac606ee1 poll_[add|remove]_fd_[from|to]_worker made boolean 2017-04-20 13:51:16 +03:00
Johan Wikman
64ab48f698 Sorting out rebase 2017-04-20 13:51:16 +03:00
Johan Wikman
274f299b54 Rebase sorting out 2017-04-20 13:51:16 +03:00
Johan Wikman
86b7eb622e DCBs now added/removed without locks
This is not globally safe yet, but all other access is directly or
indirectly related to maxadmin, which is irrelevant as far as
performance testing is concerned.
2017-04-20 13:51:16 +03:00
Johan Wikman
5138032fe5 Add shutdown support
The shutdown is now performed so that a shutdown message is
sent to all workers. When the workers receive that message, they
turn on a shutdown flag, which subsequently is checked in the poll
loop.
2017-04-20 13:51:16 +03:00
Johan Wikman
ab37333ce5 MXS_WORKER passed to poll_waitevents 2017-04-20 13:51:16 +03:00
Johan Wikman
22b39daf06 Make EPOLLET the default
The whole worker thread mechanism assumes EPOLLET and non-blocking
descriptors, so that should be the default.

TODO: In debug mode, check that the provided file descriptor indeed
      is non-blocking.
2017-04-20 13:51:16 +03:00
Johan Wikman
56c132f273 Move poll_[add|remove]_dcb to dcb.c 2017-04-20 13:51:16 +03:00
Johan Wikman
85faca74f7 Move DCB specific event handling to dcb.c 2017-04-20 13:51:16 +03:00
Johan Wikman
b11b848e66 Move all statistics gathering to poll_waitevents().
The handler callback should now return a bitmask with bits set
according to what it did when it was called. That way the actual
statistics gathering can be done in poll_waitevents() and the
handler need not be aware of any thread structs.

Actually, the only thing that needs any assistance is accept handling,
because in poll_waitevents() we do not know whether a READ event
relates to a listening or a normal socket, that is, should the
event be counted as an accept or as a read.
2017-04-20 13:51:16 +03:00
Johan Wikman
dec2bcdab2 Change DCB to MXS_POLL_DATA in statistics
Only the address of the data is used, so the code need not be
DCB specific.
2017-04-20 13:51:16 +03:00
Johan Wikman
8500a980ac Update events bitmap in poll_waitevents
This information is also generally applicable for all
poll event handlers, not just DCB. The state of the thread
is already set in poll_waitevents().
2017-04-20 13:51:16 +03:00
Johan Wikman
1e47c4aa50 Move stats-collecting to poll_waitevents()
If the stats-collecting is performed in poll_waitevents() then it
will be collected for all kinds of sockets (when other that DCB
ones can be added).
2017-04-20 13:51:16 +03:00
Johan Wikman
63141bb191 WIP: Allow the adding of any fds to the poll set
This is just a first step in a trial that will allow the addition
of any file descriptor to the general poll mechanism and hence
allow any i/o to be handled by the worker threads.

There is a structure

  typedef struct mxs_poll_data
  {
      void (*handler)(struct mxs_poll_data *data, int wid, uint32_t events);
      struct
      {
          int id;
      } thread;
  } MXS_POLL_DATA;

that any other structure (e.g. a DCB) encapsulating a file descriptor must
have as its first member (a C++ struct could basically derive from it).

That structure contains two members; 'handler' and 'thread.id'. Handler is a
pointer to a function taking a pointer to a struct mxs_poll_data, a worker thread
if and an epoll event mask as argument.

So, DCB is modified to have MXS_POLL_DATA as its first member and 'handler'
is initialized with a function that *knows* the passed MXS_POLL_DATA can
be downcast to a DCB.

process_pollq no longer exists, but is now called process_pollq_dcb. The
general stuff related to statistics etc. will be moved to poll_waitevents
itself after which the whole function is moved to dcb.c. At that point,
the handler pointer will be set in dcb_alloc().

Effectively poll.[h|c] will provide a generic mechanism for listening on
whatever descriptors and the dcb stuff will be part of dcb.[h|c].
2017-04-20 13:51:16 +03:00
Johan Wikman
58c1c1a3ca Remove BLOCKING_POLL
The code was not correct anymore and correcting it does not seem
worthwhile.
2017-03-27 11:12:37 +03:00
Johan Wikman
a9c2580da4 Compile poll.c as C++ 2017-03-24 09:35:11 +02:00