Bug #62284 too much network initialization done in accept() thread
Submitted: 28 Aug 2011 21:57 Modified: 8 Aug 2013 18:04
Reporter: Domas Mituzas Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S5 (Performance)
Version: OS:Any
Assigned to: CPU Architecture:Any
Triage: Needs Triage: D3 (Medium)

[28 Aug 2011 21:57] Domas Mituzas
Description:
accept thread is choke point when accepting connects

MySQL calls:

getsockname() to verify if returned by accept socket is valid
fcntl() to get flags
4x setsockopt() to set two timeouts, nodelay and ip_tos

all of this work could be done in a worker thread instead of main accept() loop

also, initializing vio structures and net buffers is too costly for accept thread - that could also be moved to a worker.

How to repeat:
connect to mysql

Suggested fix:
pass fd/type as part of THD, allow worker threads to initialize sockets properly
[8 Aug 2013 18:04] Paul Dubois
Noted in 5.7.2 changelog.

Previously, the main loop responsible for accepting client
connections also performed initialization of data structures related
to each connection. These initialization tasks now are delegated to
worker threads to minimize work done by the accept loop and maximize
connection acceptance rate.

As a result of this change, the bind_address, thread_cache_size, and
thread_handling system variables no longer have any effect in the
embedded server (libmysqld). Similarly, the Slow_launch_threads and
Threads_cached status variables are not meaningful in the embedded
server. These variables are no longer visible within the embedded
server and embedded applications that rely on these variables should
be modified accordingly.