Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
* [Drbd-dev] Huge latency issue with 8.2.6
@ 2008-08-12 16:31 Graham, Simon
  2008-08-16 15:22 ` Lars Ellenberg
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Graham, Simon @ 2008-08-12 16:31 UTC (permalink / raw)
  To: drbd-dev

[-- Attachment #1: Type: text/plain, Size: 3368 bytes --]

We've been benchmarking DRBD 8.2.6 and have found that some specific benchmarks (SQL) have absolutely terrible performance (a factor of 100 worse than the non DRBD case - 30 transactions per second versus 3000). These issues go away when we power off the secondary system, so it seems likely that it's somehow related to the network component. After some analysis of network traces, we found the following:

1. When we are doing 30TPS, we're also doing about 30 1K writes/s - the conclusion here is
   that one transaction needs 1 1K (2 block) write. This means we are seeing a write-to-write
   time of around 33ms. To hit the 3000TPS mark, we'd need to be handling 3000 1K writes/s
   which means a total write-to-write time of 333us

2. When we do a tcpdump on the node running the benchmark, we see the following DRBD protocol 
   consistently:
   . Node issues barrier + 1K write + unplug remote in a single packet
   . Receives barrier ack on meta-data connection 30-130us later
   . Receives Data ack on meta-data connection ~250us later (after original rq issued)
   . Receives TCP level ack on data connection 35-40ms later
   . The next write is not sent on the wire for 35-40ms

3. tcpdump on the other node shows the time between sending the barrierack and sending the
   data ack is around 120us -- this is basically the disk write time.

Conclusion 1 -- network latency has nothing to do with the horrendous perf we are seeing. What's more, we are adding (250 - write_time)us to the overall time to write the block - it seems that the disk write time is of the order of 120us, so we are adding around 130us to the total write time -- this should lead us to a max possible TPS value around 4000...

Conclusion 2 -- the problem here has to do with the time is takes the secondary to send the TCP ACK.

I should also note that we are running this system with GSO disabled -- this in turn means that the zero-copy writes done by DRBD actually turn into non-zc writes inside TCP (if you look at tcp_sendpage in tcp.c, you will see that zero-copy is disabled unless scatter gather is enabled and scatter gather is disabled if you don't have checksum offload enabled).

So, my theory is that the first write completes very quickly (around 300us), then the app issues the second write which is passed to TCP BUT TCP does not send it because it is waiting for buffers to be free which doesn't happen until the TCP level ACK is received on the data connection. In addition, the data connection is basically unidirectional -- all the other DRBD protocol messages flow on the meta-data connection.

So, what we are running into here is the TCP ACK-Delay timer on the secondary node - since we never send any data from the secondary to the primary on this connection, we have to wait for the timer to expire before acknowledging the data.

I have prototyped a change that uses the TCP_QUICKACK socket option to force acks to be sent when the UnplugRemote message is received and this has made a huge difference - in our original tests (which, in the interests of full disclosure, were run against DRBD8.0) we saw the performance go from 30TPS to 1600+TPS. 

Forcing the Ack to be sent when the UnplugRemote is received seems the right fix to me, but please comment... candidate git patch against the HEAD of 8.2 is attached.

Simon


[-- Attachment #2: 0001-Ensure-data-is-ACK-d-at-TCP-level-in-a-timely-fashio.patch --]
[-- Type: application/octet-stream, Size: 1413 bytes --]

From ff676b469fba17227df7cb6a88d3652f6c4fc061 Mon Sep 17 00:00:00 2001
From: Simon P. Graham <Simon.Graham@stratus.com>
Date: Mon, 11 Aug 2008 10:27:08 -0400
Subject: [PATCH] Ensure data is ACK'd at TCP level in a timely fashion.

---
 drbd/drbd_int.h      |    6 ++++++
 drbd/drbd_receiver.c |    3 +++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h
index 576c72c..68c5427 100644
--- a/drbd/drbd_int.h
+++ b/drbd/drbd_int.h
@@ -1522,6 +1522,12 @@ static inline void drbd_tcp_flush(struct socket *sock)
 	tcp_setsockopt(sock->sk, SOL_TCP, TCP_CORK, (char __user *)&val, sizeof(val) );
 }
 
+static inline void drbd_tcp_quickack(struct socket *sock)
+{
+	int val = 1;
+	tcp_setsockopt(sock->sk, SOL_TCP, TCP_QUICKACK, (char*)&val, sizeof(val) );
+}
+
 /* drbd_proc.c */
 extern struct proc_dir_entry *drbd_proc;
 extern struct file_operations drbd_proc_fops;
diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c
index 71e7601..c619c7a 100644
--- a/drbd/drbd_receiver.c
+++ b/drbd/drbd_receiver.c
@@ -2738,6 +2738,9 @@ STATIC int receive_UnplugRemote(struct drbd_conf *mdev, struct Drbd_Header *h)
 {
 	if (mdev->state.disk >= Inconsistent)
 		drbd_kick_lo(mdev);
+	/* Make sure we've acked all the TCP data associated
+	   with the data requests being unplugged */
+	drbd_tcp_quickack(mdev->data.socket);
 	return TRUE; /* cannot fail. */
 }
 
-- 
1.5.4.rc1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-08-16 19:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-12 16:31 [Drbd-dev] Huge latency issue with 8.2.6 Graham, Simon
2008-08-16 15:22 ` Lars Ellenberg
2008-08-16 16:44 ` Graham, Simon
2008-08-16 16:55   ` Lars Ellenberg
     [not found] ` <DA0E7D869C862D4095C265233CD1D41EEE9B7D@EXNA.corp.strat us.com>
2008-08-16 19:35   ` Graham, Simon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox