mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
iobuf: add zerocopy optimization for iobuf_read
* common/iobuf.h (iobuf_struct): Add 'e_d' substructure and members. * common/iobuf.c (IOBUF_ZEROCOPY_THRESHOLD): New. (iobuf_alloc): Clear 'iobuf->e_d'. (underflow_target): Use 'iobuf->e_d' when configured to bypass copying through 'iobuf->d.buf'. (iobuf_read): Configure 'iobuf->e_d' for 'underflow' if 'iobuf->d.buf' is empty and external buffer is larger than threshold. -- Zero-copy operation in iobuf_read() and underflow() allow bypassing 'iobuf->d.buf' for greater performance. This mainly helps OCB performance where additional memory copies through iobuf stack can take significant portion of program time. GnuPG-bug-id: T5828 Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
This commit is contained in:
parent
99e2c178c7
commit
15df88d135
2 changed files with 118 additions and 14 deletions
|
@ -202,6 +202,26 @@ struct iobuf_struct
|
|||
byte *buf;
|
||||
} d;
|
||||
|
||||
/* A external drain buffer for reading/writting data skipping internal
|
||||
draint buffer D.BUF. This allows zerocopy operation reducing
|
||||
processing overhead across filter stack.
|
||||
|
||||
Used when by iobuf_read/iobuf_write when internal buffer has been
|
||||
depleted and remaining external buffer length is large enough.
|
||||
*/
|
||||
struct
|
||||
{
|
||||
/* The external buffer provided by iobuf_read/iobuf_write caller. */
|
||||
byte *buf;
|
||||
/* The number of bytes in the external buffer. */
|
||||
size_t len;
|
||||
/* The number of bytes that were consumed from the external buffer. */
|
||||
size_t used;
|
||||
/* Gives hint for processing that the external buffer is preferred and
|
||||
that internal buffer should be consumed early. */
|
||||
int preferred;
|
||||
} e_d;
|
||||
|
||||
/* When FILTER is called to read some data, it may read some data
|
||||
and then return EOF. We can't return the EOF immediately.
|
||||
Instead, we note that we observed the EOF and when the buffer is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue