TCP vs TLS performance (2048 RSA AES)

Jordan Brown openssl at jordan.maileater.net
Sun Sep 27 17:01:20 UTC 2020


On 9/25/2020 12:17 PM, Amy Smith via openssl-users wrote:
> I mmap the file which server will send (to eliminate disk performance).

In general, this won't work.  In fact, it may make it *harder* to
eliminate disk performance from a measurement.

First, of course, mmap() isn't magic.  The data has to be read off the
disk at some point.  The only question is when.

Second, mmap() does not necessarily (and probably does not) read the
data immediately.  It sets up the paging tables so that those areas of
virtual memory are paged to/from the corresponding parts of the file. 
Just as for a page that has been kicked out of RAM into swap space, the
first access to a page causes the page to be read.

If you do a plain read() then you can be pretty confident that when the
read() returns the data has been read off the disk and into RAM.  The
same is *not* true of mmap().  If you mmap() a file and then start to
access it, the disk I/O will be in-line with your accesses.

mmap() may eliminate a memory-to-memory copy of the data, since read()
probably does not do the disk I/O directly into your process's buffer,
but mmap() might.  (Or, a bit more precisely, your mapping might point
to the same page that the kernel is using for its disk buffer.)

Of course any particular implementation could do things a bit
differently, but that's my perception of how it's usually done.

-- 
Jordan Brown, Oracle ZFS Storage Appliance, Oracle Solaris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mta.openssl.org/pipermail/openssl-users/attachments/20200927/6ec91a85/attachment-0001.html>


More information about the openssl-users mailing list