Merge lp:~mdcallag/maria/5.3fcntl into lp:maria/5.3

Proposed by Mark Callaghan
Status: Needs review
Proposed branch: lp:~mdcallag/maria/5.3fcntl
Merge into: lp:maria/5.3
Diff against target: 57 lines (+7/-5)
1 file modified
sql/net_serv.cc (+7/-5)
To merge this branch: bzr merge lp:~mdcallag/maria/5.3fcntl
Reviewer Review Type Date Requested Status
Maria-captains Pending
Review via email: mp+51226@code.launchpad.net

Description of the change

This changes mysqld to use socket timeouts rather than non-blocking, setsockopt, blocking, setsockopt. It reduces fcntl calls significantly. Many Linux kernels use the big kernel lock for fcntl and all threads can get stuck on it on a big multi-core server with 500+ concurrent connections.

With this change I double peak QPS on sysbench readonly (100k -> 200k).

The change differs from my original change in the Facebook patch. The original change broke rpl.rpl_ssl. I excluded two lines while porting.

To post a comment you must log in.
Revision history for this message
Michael Widenius (monty) wrote :

Hi!

>>>>> "Mark" == Mark Callaghan <email address hidden> writes:

Mark> Mark Callaghan has proposed merging lp:~mdcallag/maria/5.3fcntl into lp:maria.
Mark> Requested reviews:
Mark> Maria-captains (maria-captains)

Mark> For more details, see:
Mark> https://code.launchpad.net/~mdcallag/maria/5.3fcntl/+merge/51226

Mark> This changes mysqld to use socket timeouts rather than non-blocking, setsockopt, blocking, setsockopt. It reduces fcntl calls significantly. Many Linux kernels use the big kernel lock for fcntl and all threads can get stuck on it on a big multi-core server with 500+ concurrent connections.

Mark> With this change I double peak QPS on sysbench readonly (100k -> 200k).

Mark> The change differs from my original change in the Facebook patch. The original change broke rpl.rpl_ssl. I excluded two lines while porting.

I will look at this during this week. Thanks!

Regards,
Monty

Revision history for this message
Michael Widenius (monty) wrote :

Hi!

>>>>> "Mark" == Mark Callaghan <email address hidden> writes:

Mark> Mark Callaghan has proposed merging lp:~mdcallag/maria/5.3fcntl into lp:maria.
Mark> Requested reviews:
Mark> Maria-captains (maria-captains)

Mark> For more details, see:
Mark> https://code.launchpad.net/~mdcallag/maria/5.3fcntl/+merge/51226

Sorry for the delay; I have been very busy reviewing some other
big patches that needs to get into 5.3. (For the moment I don't do
anything else than reviews until all pending reviews are done)
This patch is on my TODO and hope to get to it soon.

At least, we will have time to talk about this in Lisbon.

Regards,
Monty

Unmerged revisions

2921. By Mark Callaghan

Port http://bazaar.launchpad.net/~mysqlatfacebook/mysqlatfacebook/5.1/revision/3540. When the
server is compiled with -DNO_ALARM this uses socket timeouts and avoids frequent fcntl calls.
Many Linux kernels use the big kernel lock during fcntl calls so this change can reduce
severe contention on fcntl and it doubles peak QPS for sysbench read-only from ~100k to ~200k.

This diff excludes 2 of the 7 lines changed in the original diff. I think those two lines were
incorrect and they broke the mtr test rpl.rpl_ssl

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sql/net_serv.cc'
2--- sql/net_serv.cc 2011-01-03 22:55:41 +0000
3+++ sql/net_serv.cc 2011-02-24 22:58:50 +0000
4@@ -64,7 +64,7 @@
5 can't normally do this the client should have a bigger max_allowed_packet.
6 */
7
8-#if defined(__WIN__) || !defined(MYSQL_SERVER)
9+#if (defined(__WIN__) || !defined(MYSQL_SERVER)) && !defined(NO_ALARM)
10 /* The following is because alarms doesn't work on windows. */
11 #define NO_ALARM
12 #endif
13@@ -137,7 +137,7 @@
14 if (vio != 0) /* If real connection */
15 {
16 net->fd = vio_fd(vio); /* For perl DBI/DBD */
17-#if defined(MYSQL_SERVER) && !defined(__WIN__)
18+#if defined(MYSQL_SERVER) && !defined(__WIN__) && !defined(NO_ALARM)
19 if (!(test_flags & TEST_BLOCKING))
20 {
21 my_bool old_mode;
22@@ -630,7 +630,7 @@
23 if ((long) (length= vio_write(net->vio,pos,(size_t) (end-pos))) <= 0)
24 {
25 my_bool interrupted = vio_should_retry(net->vio);
26-#if !defined(__WIN__)
27+#if !defined(NO_ALARM) && !defined(__WIN__)
28 if ((interrupted || length == 0) && !thr_alarm_in_use(&alarmed))
29 {
30 if (!thr_alarm(&alarmed, net->write_timeout, &alarm_buff))
31@@ -686,7 +686,7 @@
32 pos+=length;
33 update_statistics(thd_increment_bytes_sent(length));
34 }
35-#ifndef __WIN__
36+#if !defined(NO_ALARM) && !defined(__WIN__)
37 end:
38 #endif
39 #ifdef HAVE_COMPRESS
40@@ -824,6 +824,7 @@
41 thr_alarm(&alarmed,net->read_timeout,&alarm_buff);
42 #else
43 /* Read timeout is set in my_net_set_read_timeout */
44+ DBUG_ASSERT(net_blocking);
45 #endif /* NO_ALARM */
46
47 pos = net->buff + net->where_b; /* net->packet -4 */
48@@ -838,7 +839,8 @@
49
50 DBUG_PRINT("info",("vio_read returned %ld errno: %d",
51 (long) length, vio_errno(net->vio)));
52-#if !defined(__WIN__) || defined(MYSQL_SERVER)
53+
54+#if !defined(NO_ALARM) && (!defined(__WIN__) || defined(MYSQL_SERVER))
55 /*
56 We got an error that there was no data on the socket. We now set up
57 an alarm to not 'read forever', change the socket to non blocking

Subscribers

People subscribed via source and target branches