Re: Using a stock openssl BIO

From: Andres Freund <andres(at)anarazel(dot)de>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, Daniel Gustafsson <daniel(at)yesql(dot)se>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: Re: Using a stock openssl BIO
Date: 2021-07-15 18:41:05
Message-ID: 20210715184105.zzwy63n6re3q3iy2@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2021-07-15 13:59:26 -0400, Bruce Momjian wrote:
> On Wed, Jul 14, 2021 at 07:17:47PM -0700, Andres Freund wrote:
> > FWIW, I don't think hardware tls acceleration is a particularly crucial thing
> > for now. Outside of backups it's rare to have the symmetric encryption part of
> > tls be the problem these days thanks, to the AES etc functions in most of the
> > common CPUs.
> >
> > I don't plan to work on this, but Thomas encouraged me to mention this on the
> > list when I mention it to him.
>
> So, I am aware of CPU AES acceleration and I assume PG uses that.

Yes, it does so via openssl. But that still happens on the CPU. And
what's more, there's a lot of related work in TLS that's fairly
expensive (chunking up the data into TLS records etc). Some of the
better NICs can do that work in the happy path, so the CPU doesn't have
to do encryption nor framing. In some cases that can avoid the
to-be-sent data ever being pulled into the CPU caches, but instead it
can be DMA directly to the NIC.

In PG's case that's particularly interesting when sending out file data
in bulk, say in basebackup.c or walsender.c - the data can be sent via
sendfile(), so it never goes to userspace.

Here's an overview of the kernel TLS / TLS offload
https://legacy.netdevconf.info/1.2/papers/ktls.pdf

> It is the public key certificate verification part of TLS that we
> don't use hardware acceleration for, right?

That's true, but separate from what I was talking about. For most
database workloads the public key stuff shouldn't be a major piece,
because connection establishment shouldn't be that frequent...

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Cramer 2021-07-15 18:51:53 Re: pg_upgrade does not upgrade pg_stat_statements properly
Previous Message David G. Johnston 2021-07-15 18:30:35 Re: pg_upgrade does not upgrade pg_stat_statements properly