[PATCH] when we need to transfer data between file and socket we prefer to use sendfile instead of write because we save the copy to a buffer

Maxim Dounin mdounin at mdounin.ru
Thu Apr 18 13:07:33 UTC 2019


Hello!

On Thu, Apr 18, 2019 at 10:32:56AM +0300, ben ben ishay wrote:

> # HG changeset patch
> # User ben ben ishay <benishay at mellanox.com>
> # Date 1555572726 -10800
> #      Thu Apr 18 10:32:06 2019 +0300
> # Node ID bb4c564a9f1c5c721c192e6188967c19aabbc0b9
> # Parent  a6e23e343081b79eb924da985a414909310aa7a3
> when we need to transfer data between file and socket we prefer to use sendfile instead of write because we save the copy to a buffer.
> the use of sendfile is possible in openssl only if it support ktls(the master of openssl support ktls) otherwise there is a copy of the data to userspace for encryption in any case (this paper explain this https://netdevconf.org/1.2/papers/ktls.pdf ).
> the patch  change the flow when the request is to send data over ssl and also the nginx use openssl that support ktls, the new flow using the sendfile function that tcp use for send data (ngx_linux_sendfile_chain).
> the performence with this patch applied was check with apib benchmark(this is the source https://github.com/apigee/apib),one machine run nginx and the other machine that connect back to back to the first one run apib with this comand: ./apib -c <num of connection> -d 30 https://<ip address>/<file name to send>.
> the file size was 100K.
> 
> the result display  in this table , each value represnt average throughput in GBps of 10 runs.
> 
> num of connection   | regular nginx  | new nginx
>  	1		5		5.2
>  	2		7.5		8.5
>  	3		7.7		9
> 
> this result prove that this patch increase nginx performance and thus is useful.

In no particular order:

- Please read http://nginx.org/en/docs/contributing_changes.html for 
  basic tips on how to submit patches.  In particular, please make 
  sure to follow nginx coding style.

- Note well that at least one bug in your code is directly related 
  to incorrect indentation and failure to properly use curly 
  brackets as explicitly required by the coding style.  The style 
  is there to prevent such accidental bugs.

- When you update your patches based on the feedback given, 
  consider replying to the thread in question instead of 
  posting a new thread.  If for some reason you think a new thread 
  will be better, describe these reasons and post a reference to 
  the old thread.  Also, make sure to describe changes you've 
  made based on the feedback.

- The SSL_sendfile() call you are using in this version does not 
  seem to exists in any published version of OpenSSL, including 
  github repo.  This is not going to work.

- The approach you are using - that is, introducing changes into 
  ngx_linux_sendfile_chain.c - is not portable, and is not going 
  to work on other platforms if/when appropriate kernel level and 
  OpenSSL level support will be available.  As suggested in the 
  previous thread, this should be something handled at the 
  ngx_event_openssl.c level.

[...]

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list