-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#24290] Build postgres --with-lz4 using thirdparty headers
Summary: ### Enabling LZ4 compression Postgres has a feature called [[ https://www.postgresql.org/docs/current/storage-toast.html | TOAST compression ]] that automatically compresses large attributes. We currently use a limited version of TOAST to compress large metadata values in the in-memory catcache (introduced in D29916). However, this feature is disabled by default because the current compression algorithm that Postgres uses, `pglz`, is very slow to compress/decompress. With the PG15 upgrade, Postgres now supports a new compression library, `lz4`, which has almost 0 compression/decompression overhead and compression ratios equal to the old `pglz` algorithm. In order to take advantage of this algorithm, we need to point the Postgres `configure` script to the lz4 library. The script relies on the `.pc` package config file to tell it where the library's headers/object files are. We already are building the `lz4` library in `yugabyte-db-thirdparty` because we are using it in DocDB, but we are using an old version that did not generate a package config file. Recently, [[ yugabyte/yugabyte-db-thirdparty@e037b77 | we switched to a newer version of lz4 ]] that generates this file. Previously, when we tried to build postgres with lz4, it would find the lz4 object files built in `yugabyte-db-thirdparty` but not the header files, resulting in a compiler error. However, with the latest updates to thirdparty, the `.pc` file is generated and we find both the header and the object files. Test Plan: Automated test for lz4 compression: ``` ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressTable' ``` Manual test to verify that the correct header is included: `./yb_build.sh`, then verify that the thirdparty header is being included in `toast_compression.c`: ``` $ grep lz4 build/debug-clang17-dynamic-ninja/postgres_build/src/backend/access/common/.deps/toast_compression.Po /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20240922072704-224279f6e8-amzn2-x86_64-clang17/installed/common/include/lz4.h \ /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20240922072704-224279f6e8-amzn2-x86_64-clang17/installed/common/include/lz4.h: ``` To verify that the right shared library is being linked in: ``` $ ldd ./build/latest/postgres/bin/postgres | grep lz4 liblz4.so.1.5 => /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20240922072704-224279f6e8-amzn2-x86_64-clang17/installed/common/lib/liblz4.so.1.5 (0x00007f8bd6880000) ``` Reviewers: jason Reviewed By: jason Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D38727
- Loading branch information
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.