[PATCH grout] api: optimize send small payloads
Morten Brørup
mb at smartsharesystems.com
Mon Jul 6 12:41:19 CEST 2026
> From: Robin Jarry [mailto:rjarry at redhat.com]
> Sent: Monday, 6 July 2026 12.02
>
> Morten Brørup, Jun 13, 2026 at 11:52:
> > Copy small payloads into buffer holding both header and payload,
> > and send as one, instead of sending header and payload separately.
> >
> > Signed-off-by: Morten Brørup <mb at smartsharesystems.com>
> > ---
> > api/gr_api_client_impl.h | 29 ++++++++++++++++-----
> > main/api.c | 55 ++++++++++++++++++++++++++++++--------
> --
> > 2 files changed, 63 insertions(+), 21 deletions(-)
>
> Hi Morten,
>
> Did you measure any improvement after this patch?
I did not profile it, no.
The send() syscall is quite expensive, so combining two calls into one should give Grout API transactions a measurable performance boost.
The changes related to the bufferevent_write() lib call were added mainly for symmetry.
So I set a much lower merge threshold.
I think the performance difference negligible.
BTW, my changes here also fixes a bug: The payload was unconditionally written, regardless of writing the header failed.
Honestly, I just started familiarizing myself with Grout a few weeks ago, and stumbled across this (inefficiency of calling send() twice) while trying to learn about Grout's API mechanisms. So I thought I'd add this simple optimization.
More information about the grout
mailing list