Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sFZ9l-003WPT-0t for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Jun 2024 12:57:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sFZ9j-00BiY3-DA for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Jun 2024 12:57:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sFZ9j-00BiXv-2a for pgsql-hackers@lists.postgresql.org; Fri, 07 Jun 2024 12:57:19 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sFZ9g-000SiF-9L for pgsql-hackers@lists.postgresql.org; Fri, 07 Jun 2024 12:57:18 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4215fc19abfso14940965e9.3 for ; Fri, 07 Jun 2024 05:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1717765035; x=1718369835; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=yzNyzt5pjKBaC/e+j8VDApNNP+kM1dhtM7d/o4h53T0=; b=GMmSsxJ0d+L2ErIlmYpU/vnJtHNFhxAFG2dz0MV6Md/OBBNrWwuhUuN9Vd01eJ70ka za2ZX0MzpQR5Bwl2Ssqjmbu1GH//wVSu17fI4jGJsLrxUtkHzguV+UOQHVF9T5W1RkHQ Z6rBP7iwh7OtPDLD8djVMsUgs+zgc8keKRotGAEiibeKkEwGB71jByvn0eE+s97nShd0 flhjLmsF5E1qZRK54spbDuqUu27WtUK0ACYNCEQhQvzelQPpxfaicCYhFxvT9QKdyefm k5olSK8elVoMFg4F/7Y+TmIe2hbObxI+0QFaHJdFEGGQ4TmpBDECgz3xZ2i407BawALk zyRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717765035; x=1718369835; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yzNyzt5pjKBaC/e+j8VDApNNP+kM1dhtM7d/o4h53T0=; b=f5QGiYskPk4qMGETGUIJNlJOMZZopNG0bI8SHFJzy4dslMZXyVEgPOzuRJm+tAC1oc 8HtEb3f9ohY6AUCYN1M4+qwXyKVqo8nRnKGmd64oIkE1hjnVPduDzHR/AVotM8daygTl SKsWKu9tp6ZzwCCRa6vHAHPbIKrqkif/Rq7eau4gV9VgnKo9rLM7G1aXOfpOP9hyJ4iQ iJyDuXUL7aavwAEOtyy6gwHsQWcb+JVx4sFBDYwfVcV//lBCxzrfEYhdYa4Kja0ytmvw /mP8EUfZOwnDtX73mJJL9NNhOxbB+Gw52VxwuXhaNl5X5zRHma7A++6JwMzqrrVLKeZC I/kw== X-Forwarded-Encrypted: i=1; AJvYcCV7OdbqOedbXMoCAn0qb3SpcN97fbhT0tTDw/WSAQgeWQU7BzLQQp9IdMcQ3im1N5uYPQnqJ40Cz473a56hlNTxsK7IfX/rYXmq7Wxi+IvBgSKC X-Gm-Message-State: AOJu0YwAMuhTC3c1Sp/W+L26wuBJuo2RuK2EZVISaP8HFYhET34CrZ0i QR+ypIKGjmUu++zTFNCI+keTA5N83xLgLH/FndP+O+tzyn52hNZxd7sfWV2i5A== X-Google-Smtp-Source: AGHT+IH0I1yV9VH330e6qQ1+N0k5ONl/712BlR15awIfBt4IUiDlewSUNWI3MUSQZKft6wlwMKHvRg== X-Received: by 2002:a05:600c:9:b0:421:2b3e:3a22 with SMTP id 5b1f17b1804b1-421649f4d86mr21167235e9.14.1717765034891; Fri, 07 Jun 2024 05:57:14 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f0b876d80sm854623f8f.109.2024.06.07.05.57.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Jun 2024 05:57:14 -0700 (PDT) Message-ID: <0a920720-892b-452f-8494-a5fcb59df418@enterprisedb.com> Date: Fri, 7 Jun 2024 14:57:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Compress ReorderBuffer spill files using LZ4 To: Alvaro Herrera , Amit Kapila Cc: Julien Tachoires , pgsql-hackers@lists.postgresql.org References: <202406061424.sij74o57lpnk@alvherre.pgsql> Content-Language: en-US From: Tomas Vondra In-Reply-To: <202406061424.sij74o57lpnk@alvherre.pgsql> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/6/24 16:24, Alvaro Herrera wrote: > On 2024-Jun-06, Amit Kapila wrote: > >> On Thu, Jun 6, 2024 at 4:28 PM Julien Tachoires wrote: >>> >>> When the content of a large transaction (size exceeding >>> logical_decoding_work_mem) and its sub-transactions has to be >>> reordered during logical decoding, then, all the changes are written >>> on disk in temporary files located in pg_replslot/. >>> Decoding very large transactions by multiple replication slots can >>> lead to disk space saturation and high I/O utilization. > > I like the general idea of compressing the output of logical decoding. > It's not so clear to me that we only want to do so for spilling to disk; > for instance, if the two nodes communicate over a slow network, it may > even be beneficial to compress when streaming, so to this question: > >> Why can't one use 'streaming' option to send changes to the client >> once it reaches the configured limit of 'logical_decoding_work_mem'? > > I would say that streaming doesn't necessarily have to mean we don't > want compression, because for some users it might be beneficial. > > I think a GUC would be a good idea. Also, what if for whatever reason > you want a different compression algorithm or different compression > parameters? Looking at the existing compression UI we offer in > pg_basebackup, perhaps you could add something like this: > > compress_logical_decoding = none > compress_logical_decoding = lz4:42 > compress_logical_decoding = spill-zstd:99 > > "none" says to never use compression (perhaps should be the default), > "lz4:42" says to use lz4 with parameters 42 on both spilling and > streaming, and "spill-zstd:99" says to use Zstd with parameter 99 but > only for spilling to disk. > > (I don't mean to say that you should implement Zstd compression with > this patch, only that you should choose the implementation so that > adding Zstd support (or whatever) later is just a matter of adding some > branches here and there. With the current #ifdef you propose, it's hard > to do that. Maybe separate the parts that depend on the specific > algorithm to algorithm-agnostic functions.) > I haven't been following the "libpq compression" thread, but wouldn't that also do compression for the streaming case? That was my assumption, at least, and it seems like the right way - we probably don't want to patch every place that sends data over network independently, right? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company