Skip to contentSkip to conversation

16% regression on 10G caused by TCP small queues

DISCUSSION Stephen Hemminger 5 participants 11 messages Oct 24, 2013 – Oct 27, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

In the course of testing routing functionality, I discovered a that the single flow TCP throughput was much worse than expected. At first, it looked like a router problem, or maybe because one end was a FreeBSD system (which has noticeably slower TCP performance). But reducing it down to two systems directly connected over 10G (ixgbe) found the problem.

With a single TCP flow, in 3.5 kernel the performance with iperf is 9.41 Gbit/sec which is at the link limit for TCP with timestamps etc. But in 3.6 and later the throughput dropped to 7.9 Gbit/sec which is a regression of 16%.

Doing bisect shows that the commit causing this is:

commit 46d3ceabd8d98ed0ad10f20c595ca784e34786c5
Author: Eric Dumazet <[email protected]>
Date: Wed Jul 11 05:50:31 2012 +0000

tcp: TCP Small Queues

This introduce TSQ (TCP Small Queues)

There are several options at this point:
0. Ignore it. Sorry, this is not acceptable. People do transfer files over 10G and expect line rate!

1. Rip it out. which adds to the buffer bloat.
This is a throughput vs latency tradeoff.

2. Neuter it by making TCP small queues configurable and default off. Allows people who are willing to sacrifice performance go ahead and enable it.

3. Tweak it. Make the default queue value in kernel big enough that no loss is observable.

4. Do something smarter like a dynamic TCP small queue that adapts.

#1 lore raw
Quoted 4 lines · Stephen Hemminger

In the course of testing routing functionality, I discovered a that the single flow TCP throughput was much worse than expected. At first, it looked like a router problem, or maybe because one end was a FreeBSD system (which has noticeably slower TCP performance). But reducing it down to two systems directly connected over 10G (ixgbe) found the problem.

...

Quoted 1 line

4. Do something smarter like a dynamic TCP small queue that adapts.

Yep, Eric made TSQ dynamic a few weeks ago, and mentioned that his commit helps a single flow on 10Gbps link:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c9eeec26e32e087359160406f96e0949b3cc6f10

Can you please check the performance in your setup on 3.12-rc4 or newer? :-)

Thanks!

neal

---

commit c9eeec26e32e087359160406f96e0949b3cc6f10

Author: Eric Dumazet <[email protected]>
Date:   Fri Sep 27 03:28:54 2013 -0700

tcp: TSQ can use a dynamic limit

When TCP Small Queues was added, we used a sysctl to limit amount of packets queues on Qdisc/device queues for a given TCP flow.

Problem is this limit is either too big for low rates, or too small for high rates.

Now TCP stack has rate estimation in sk->sk_pacing_rate, and TSO auto sizing, it can better control number of packets in Qdisc/device queues.

New limit is two packets or at least 1 to 2 ms worth of packets.

Low rates flows benefit from this patch by having even smaller number of packets in queues, allowing for faster recovery, better RTT estimations.

High rates flows benefit from this patch by allowing more than 2 packets in flight as we had reports this was a limiting factor to reach line rate. [ In particular if TX completion is delayed because of coalescing parameters ]

Example for a single flow on 10Gbp link controlled by FQ/pacing

14 packets in flight instead of 2
...

#2 lore raw
Quoted 12 lines · Neal Cardwell
Quoted 4 lines · Stephen Hemminger

In the course of testing routing functionality, I discovered a that the single flow TCP throughput was much worse than expected. At first, it looked like a router problem, or maybe because one end was a FreeBSD system (which has noticeably slower TCP performance). But reducing it down to two systems directly connected over 10G (ixgbe) found the problem.

...

Quoted 1 line

4. Do something smarter like a dynamic TCP small queue that adapts.

Yep, Eric made TSQ dynamic a few weeks ago, and mentioned that his commit helps a single flow on 10Gbps link:

Quoted 7 lines

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c9eeec26e32e087359160406f96e0949b3cc6f10

Can you please check the performance in your setup on 3.12-rc4 or newer? :-)

Thanks!

neal

I will check 3.12, but what about users on 3.10 which is the LTS kernel used by most distros?

maintainer
#3 lore raw

From: Stephen Hemminger <[email protected]>
Date: Wed, 23 Oct 2013 20:09:49 -0700

Quoted 2 lines

I will check 3.12, but what about users on 3.10 which is the LTS kernel used by most distros?

The fix will be backported to -stable, relax Stephen.

#4 lore raw
Quoted 5 lines · On Wed, 23 Oct 2013 23:38:16 -0400 (EDT) David Miller <[email protected]>…

From: Stephen Hemminger <[email protected]>
Date: Wed, 23 Oct 2013 20:09:49 -0700

Quoted 2 lines

I will check 3.12, but what about users on 3.10 which is the LTS kernel used by most distros?

3.12-rc6 gets line rate again (9.41 Gbit/sec)

Quoted 1 line

The fix will be backported to -stable, relax Stephen.

Sorry, thought sk_pacing_rate depended on FQ qdisc but it is other way around. In which case doing merge of these two was sufficient to fix the problem. With a minor manual fix up to tcp.h.

commit 95bd09eb27507691520d39ee1044d6ad831c1168

Author: Eric Dumazet <[email protected]>
Date:   Tue Aug 27 05:46:32 2013 -0700

tcp: TSO packets automatic sizing

commit c9eeec26e32e087359160406f96e0949b3cc6f10

Author: Eric Dumazet <[email protected]>
Date:   Fri Sep 27 03:28:54 2013 -0700

tcp: TSQ can use a dynamic limit

#5 lore raw
Quoted 22 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 23 Oct 2013 23:38:16 -0400 (EDT) David Miller <[email protected]>…

From: Stephen Hemminger <[email protected]>
Date: Wed, 23 Oct 2013 20:09:49 -0700

Quoted 2 lines

I will check 3.12, but what about users on 3.10 which is the LTS kernel used by most distros?

3.12-rc6 gets line rate again (9.41 Gbit/sec)

Quoted 1 line

The fix will be backported to -stable, relax Stephen.

Sorry, thought sk_pacing_rate depended on FQ qdisc but it is other way around. In which case doing merge of these two was sufficient to fix the problem. With a minor manual fix up to tcp.h.

commit 95bd09eb27507691520d39ee1044d6ad831c1168

Author: Eric Dumazet <[email protected]>
Date:   Tue Aug 27 05:46:32 2013 -0700
Quoted 7 lines

tcp: TSO packets automatic sizing

commit c9eeec26e32e087359160406f96e0949b3cc6f10

Author: Eric Dumazet <[email protected]>
Date:   Fri Sep 27 03:28:54 2013 -0700

tcp: TSQ can use a dynamic limit

Perfect, thanks for testing Stephen !

#6 lore raw
In reply to Stephen Hemminger
Quoted 9 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 23 Oct 2013 23:38:16 -0400 (EDT) David Miller <[email protected]>…

From: Stephen Hemminger <[email protected]>
Date: Wed, 23 Oct 2013 20:09:49 -0700

Quoted 2 lines

I will check 3.12, but what about users on 3.10 which is the LTS kernel used by most distros?

Quoted 7 lines

3.12-rc6 gets line rate again (9.41 Gbit/sec)

Quoted 1 line

The fix will be backported to -stable, relax Stephen.

Sorry, thought sk_pacing_rate depended on FQ qdisc but it is other way around. In which case doing merge of these two was sufficient to fix the problem. With a minor manual fix up to tcp.h.

Btw what is the NIC you are using ?

I also had to patch mlx4 driver because it had too big coalescing parameters, it was before TCP Small Queue dynamic sizing, but its worth noting that for the initial ramp up (when flow sk_pacing_rate is low because initial cwin is 10), it might make a difference

This was

commit ecfd2ce1a9d5e6376ff5c00b366345160abdbbb7

Author: Eric Dumazet <[email protected]>
Date:   Mon Nov 5 16:20:42 2012 +0000

mlx4: change TX coalescing defaults

mlx4 currently uses a too high tx coalescing setting, deferring TX completion interrupts by up to 128 us.

With the recent skb_orphan() removal in commit 8112ec3b872, performance of a single TCP flow is capped to ~4 Gbps, unless we increase tcp_limit_output_bytes.

I suggest using 16 us instead of 128 us, allowing a finer control.

Performance of a single TCP flow is restored to previous levels, while keeping TCP small queues fully enabled with default sysctl.

This patch is also a BQL prereq.

#7 lore raw
Quoted 1 line · Eric Dumazet

Btw what is the NIC you are using ?

Oh well I read you mail and saw ixgbe was mentioned ;)

maintainer
#8 lore raw
In reply to Stephen Hemminger

From: Stephen Hemminger <[email protected]>
Date: Wed, 23 Oct 2013 21:45:57 -0700

Quoted 3 lines

Sorry, thought sk_pacing_rate depended on FQ qdisc but it is other way around. In which case doing merge of these two was sufficient to fix the problem. With a minor manual fix up to tcp.h.

I know, I already have a half-built tree of -stable submissions that does exactlty this.

#9 lore raw
Quoted 9 lines · David Miller

From: Stephen Hemminger <[email protected]>
Date: Wed, 23 Oct 2013 21:45:57 -0700

Quoted 3 lines

Sorry, thought sk_pacing_rate depended on FQ qdisc but it is other way around. In which case doing merge of these two was sufficient to fix the problem. With a minor manual fix up to tcp.h.

I know, I already have a half-built tree of -stable submissions that does exactlty this.

I know that the "fq" qdisc is not exactly a -stable thing, but if it's simpler to include it rather than sort through the patch sets, I'm all for it.

maintainer
#10 lore raw

From: Dave Taht <[email protected]>
Date: Sat, 26 Oct 2013 21:33:52 -0700

Quoted 8 lines · David Miller
Quoted 7 lines

From: Stephen Hemminger <[email protected]>
Date: Wed, 23 Oct 2013 21:45:57 -0700

Quoted 3 lines

Sorry, thought sk_pacing_rate depended on FQ qdisc but it is other way around. In which case doing merge of these two was sufficient to fix the problem. With a minor manual fix up to tcp.h.

Quoted 5 lines
Quoted 2 lines

I know, I already have a half-built tree of -stable submissions that does exactlty this.

I know that the "fq" qdisc is not exactly a -stable thing, but if it's simpler to include it rather than sort through the patch sets, I'm all for it.

I'm not including 'fq' and it's absolutely not necessary to fix this bug.

'fq' is only incidentary to this bug fix because it just so happens to make use of sk->sk_pacing_rate. There is no other connection between these two things.