Pool of Threads dispatching queries to DB servers

Registered by Stewart Smith

Instead of the one thread per connection model we currently have, make it possible to choose to use a pool of threads instead.

When used with a non blocking client library such as libdrizzle or the MariaDB one, this should be much more efficient than the thread per connection model.

Blueprint information

Status:
Complete
Approver:
Stewart Smith
Priority:
Undefined
Drafter:
Stewart Smith
Direction:
Needs approval
Assignee:
None
Definition:
Approved
Series goal:
Accepted for 1.0
Implementation:
Implemented
Milestone target:
milestone icon 0.6
Started by
Stewart Smith
Completed by
Stewart Smith

Sprints

Whiteboard

It can be done with the following steps:

1) Create interface for Dispatcher class, make one more type of plugin and move current implementation to plugin;

2) Use shared_ptr to queries queue instead of queries queue itself in DBThread class. The current implementation will create new instance of queue for each DBThread instance but thread pool will have one queue for all threads;

3) Remove pointer to DBThreadState from DBThread class. As we have pool of connection threads we should not store DB thread state in connection class;

4) Create new dispatcher plugin. Let's name it as ConnectionsPoolDispatcher. There will be --connections-pool-thread-no command line option wich allows to set threads number in threads pool;

a) create N DBThread instances with the pointers to the one queue of QueryEntries objects;

b) keep pointer to DBConnectionState in the descendants of QueryEntry class;

c) tcpdump plugin becomes responsible for managing it connection states;

d) Dispatcher::dispatch() just adds new QueryEntry to the end of queries queue;

e) Dispatcher::finish_and_wait() does nothing;

f) Dispatcher::finish_all_and_wait() pushes "finish" query entry to the queue and join to all spawned threads. If any thread pops such entry it invokes tbb::concurrent_bounded_queue::abort() to finish other threads.

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.