Re: Protocol Compression (fourth attempt)

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Protocol Compression (fourth attempt)
Date: 2026-10-23 13:29:55
Message-ID: 9CCDE409-7813-4A2E-A15C-4D755EF54178@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Anthonin,

Thanks! Attached is a revision based on your v1. I kept your msg_buffer
refactoring as a separate patch, and retained PQcommMethods and decoded
message tracing. The second patch brings over client-to-server COPY
compression and reusable buffers from my prototype. The trace
checks use the existing libpq testclient.

As discussed, this version negotiates Zstandard at startup and
compresses DataRow/CopyData. Backend frames end at every ReadyForQuery,
frontend frames at CopyDone/CopyFail. Other codecs and levels, session
control, public thresholds and pg_stat_* counters are left for later.

On 30 Sep 2026, Anthonin Bonnefoy wrote:
> Maybe a combination of both (limited input size
> with at least x full messages) could work?

I used a 32 KiB input limit without a message-count minimum. Large
messages can span wrappers. Existing flush points still apply, so a
small query result does not wait for the buffer to fill.

In a local TCP comparison of 100000 rows with 80-byte payloads, the
first row arrived in about 0.5 ms with this revision versus 13 ms with
your v1.

You are right that libpq cannot deliver an incomplete row. Partial
flushing bounds buffering and allows compression, transfer and
decompression to overlap. A single large row still has to be decoded
in full. I would keep the threshold internal while we compare more
workloads.

Does this look like a useful common base?

Thank you!

Best regards, Andrey Borodin.

Attachment Content-Type Size
v2-0001-Create-a-new-msg_buffer-struct-for-PGconn-s-inBuf.patch application/octet-stream 61.1 KB
unknown_filename text/plain 1 byte
v2-0002-Add-compression-to-the-frontend-backend-protocol.patch application/octet-stream 102.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sho Ito 2026-10-23 13:39:58 [PATCH v1] Fix tab completion for REINDEX SYSTEM
Previous Message CyberNative AI 2026-10-23 13:28:30 Re: Skip prefetch for block references that follow a FPW or WILL_INIT of the same block