All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net/smc: Improvements for TCP_CORK and sendfile()
@ 2022-01-30 18:02 Tony Lu
  2022-01-30 18:02 ` [PATCH net-next 1/3] net/smc: Send directly when TCP_CORK is cleared Tony Lu
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Tony Lu @ 2022-01-30 18:02 UTC (permalink / raw)
  To: kgraul, kuba, davem; +Cc: netdev, linux-s390

Currently, SMC use default implement for syscall sendfile() [1], which
is wildly used in nginx and big data sences. Usually, applications use
sendfile() with TCP_CORK:

fstat(20, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
setsockopt(19, SOL_TCP, TCP_CORK, [1], 4) = 0
writev(19, [{iov_base="HTTP/1.1 200 OK\r\nServer: nginx/1"..., iov_len=240}], 1) = 240
sendfile(19, 20, [0] => [4096], 4096)   = 4096
close(20)                               = 0
setsockopt(19, SOL_TCP, TCP_CORK, [0], 4) = 0

The above is an example of Nginx, when sendfile() on, Nginx first
enables TCP_CORK, write headers, the data will not be sent. Then call
sendfile(), it reads file and write to sndbuf. When TCP_CORK is cleared,
all pending data is sent out.

The performance of the default implement of sendfile is lower than when
it is off. After investigation, it shows two parts to improve:
- unnecessary lock contention of delayed work
- less data per send than when sendfile off

Patch #1 tries to reduce lock_sock() contention in smc_tx_work().
Patch #2 removes timed work for corking, and let applications control
it. See TCP_CORK [2] MSG_MORE [3].
Patch #3 adds MSG_SENDPAGE_NOTLAST for corking more data when
sendfile().

Test environments:
- CPU Intel Xeon Platinum 8 core, mem 32 GiB, nic Mellanox CX4
- socket sndbuf / rcvbuf: 16384 / 131072 bytes
- server: smc_run nginx
- client: smc_run ./wrk -c 100 -t 2 -d 30 http://192.168.100.1:8080/4k.html
- payload: 4KB local disk file

Items                     QPS
sendfile off        272477.10
sendfile on (orig)  223622.79
sendfile on (this)  395847.21

This benchmark shows +45.28% improvement compared with sendfile off, and
+77.02% compared with original sendfile implement.

[1] https://man7.org/linux/man-pages/man2/sendfile.2.html
[2] https://linux.die.net/man/7/tcp
[3] https://man7.org/linux/man-pages/man2/send.2.html

Tony Lu (3):
  net/smc: Send directly when TCP_CORK is cleared
  net/smc: Remove corked dealyed work
  net/smc: Cork when sendpage with MSG_SENDPAGE_NOTLAST flag

 net/smc/af_smc.c |  8 ++++---
 net/smc/smc_tx.c | 59 ++++++++++++++++++++++++++++++++----------------
 net/smc/smc_tx.h |  3 +++
 3 files changed, 47 insertions(+), 23 deletions(-)

-- 
2.32.0.3.g01195cf9f


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

end of thread, other threads:[~2022-02-14 12:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-30 18:02 [PATCH net-next 0/3] net/smc: Improvements for TCP_CORK and sendfile() Tony Lu
2022-01-30 18:02 ` [PATCH net-next 1/3] net/smc: Send directly when TCP_CORK is cleared Tony Lu
2022-01-31 19:13   ` Stefan Raspl
2022-02-07 10:03     ` Tony Lu
2022-02-11  6:52     ` [PATCH net-next] net/smc: Add comment for smc_tx_pending Tony Lu
2022-02-14 11:20       ` patchwork-bot+netdevbpf
2022-01-30 18:02 ` [PATCH net-next 2/3] net/smc: Remove corked dealyed work Tony Lu
2022-01-31 19:40   ` Stefan Raspl
2022-02-11  9:10     ` Tony Lu
2022-02-14 10:29       ` Stefan Raspl
2022-02-14 12:10         ` Tony Lu
2022-01-30 18:02 ` [PATCH net-next 3/3] net/smc: Cork when sendpage with MSG_SENDPAGE_NOTLAST flag Tony Lu
2022-01-31 19:46   ` Stefan Raspl
2022-01-31 19:42 ` [PATCH net-next 0/3] net/smc: Improvements for TCP_CORK and sendfile() Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.