Repository navigation
feat: optional zstd compression of block and undo files #7939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
782d37e
9dba17d
4fb54c1
d674946
67e5350
4c8863c
ba71ee0
d1e1aa6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -149,6 +149,12 @@ AC_ARG_WITH([bdb], | |||||||||||||
| [use_bdb=$withval], | ||||||||||||||
| [use_bdb=auto]) | ||||||||||||||
|
|
||||||||||||||
| AC_ARG_WITH([zstd], | ||||||||||||||
| [AS_HELP_STRING([--without-zstd], | ||||||||||||||
| [disable zstd compression of block files and masternode lists (default is enabled if libzstd is found)])], | ||||||||||||||
| [use_zstd=$withval], | ||||||||||||||
| [use_zstd=auto]) | ||||||||||||||
|
Comment on lines
+152
to
+156
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: Correct the zstd help text to describe block and undo files The --without-zstd help text says zstd compresses block files and masternode lists, but this PR adds compression only for block and undo records. The same inaccurate wording appears in both corresponding sections of doc/build-unix.md. Update all three occurrences so the build documentation matches the implementation.
Suggested change
source: |
||||||||||||||
|
|
||||||||||||||
| AC_ARG_ENABLE([usdt], | ||||||||||||||
| [AS_HELP_STRING([--enable-usdt], | ||||||||||||||
| [enable tracepoints for Userspace, Statically Defined Tracing (default is yes if sys/sdt.h is found)])], | ||||||||||||||
|
|
@@ -1694,7 +1700,23 @@ AC_CHECK_LIB([gmp], [__gmpz_init],GMP_LIBS=-lgmp, AC_MSG_ERROR(libgmp missing)) | |||||||||||||
| CPPFLAGS="$TEMP_CPPFLAGS" | ||||||||||||||
| LDFLAGS="$TEMP_LDFLAGS" | ||||||||||||||
|
|
||||||||||||||
| dnl zstd check | ||||||||||||||
| if test "$use_zstd" != "no"; then | ||||||||||||||
| PKG_CHECK_MODULES([ZSTD], [libzstd >= 1.4.0], | ||||||||||||||
| [AC_DEFINE([ENABLE_ZSTD], [1], [Define this symbol to enable zstd compression]) | ||||||||||||||
| use_zstd=yes], | ||||||||||||||
| [if test "$use_zstd" = "yes"; then | ||||||||||||||
| AC_MSG_ERROR([libzstd version 1.4.0 or greater not found.]) | ||||||||||||||
| fi | ||||||||||||||
| AC_MSG_WARN([libzstd version 1.4.0 or greater not found, disabling zstd compression]) | ||||||||||||||
| use_zstd=no]) | ||||||||||||||
| fi | ||||||||||||||
| if test "$use_zstd" = "yes" && test "$suppress_external_warnings" != "no"; then | ||||||||||||||
| ZSTD_CFLAGS=SUPPRESS_WARNINGS($ZSTD_CFLAGS) | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| AM_CONDITIONAL([ENABLE_ZMQ], [test "$use_zmq" = "yes"]) | ||||||||||||||
| AM_CONDITIONAL([ENABLE_ZSTD], [test "$use_zstd" = "yes"]) | ||||||||||||||
|
|
||||||||||||||
| dnl libmultiprocess library check | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -2103,6 +2125,7 @@ if test $bitcoin_enable_qt != "no"; then | |||||||||||||
| echo " with qr = $use_qr" | ||||||||||||||
| fi | ||||||||||||||
| echo " with zmq = $use_zmq" | ||||||||||||||
| echo " with zstd = $use_zstd" | ||||||||||||||
| if test $enable_fuzz = "no"; then | ||||||||||||||
| echo " with test = $use_tests" | ||||||||||||||
| else | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package=zstd | ||
| $(package)_version=1.5.7 | ||
| $(package)_download_path=https://github.com/facebook/zstd/releases/download/v$($(package)_version) | ||
| $(package)_file_name=$(package)-$($(package)_version).tar.gz | ||
| $(package)_sha256_hash=eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3 | ||
|
|
||
| define $(package)_set_vars | ||
| $(package)_build_opts=CC="$($(package)_cc)" AR="$($(package)_ar)" | ||
| $(package)_build_opts+=CFLAGS="$($(package)_cflags) $($(package)_cppflags)" LDFLAGS="$($(package)_ldflags)" | ||
| $(package)_build_opts+=ZSTD_LEGACY_SUPPORT=0 ZSTD_LIB_DEPRECATED=0 ZSTD_LIB_DICTBUILDER=0 | ||
| endef | ||
|
|
||
| define $(package)_build_cmds | ||
| $(MAKE) -C lib libzstd.a $($(package)_build_opts) | ||
| endef | ||
|
|
||
| define $(package)_stage_cmds | ||
| $(MAKE) -C lib install-static install-includes install-pc PREFIX=$(host_prefix) DESTDIR=$($(package)_staging_dir) $($(package)_build_opts) | ||
| endef |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| Block storage | ||
| ------------- | ||
|
|
||
| Block files (`blocks/blk*.dat`) and undo files (`blocks/rev*.dat`) can now be written | ||
| zstd-compressed, one frame per record, which saves about a fifth of the space of new block files | ||
| and about a quarter of new undo files. The new `-blockcompression=<level>` option selects the zstd | ||
| level. It defaults to 0 in this release, which stores records exactly as before, so nothing changes | ||
| on disk unless the option is set. Level 3 is the recommended setting when opting in; levels above 5 | ||
| cost several times more CPU for no measurable gain and produce a startup warning. A future release | ||
| is planned to enable compression by default. | ||
|
|
||
| Files written by earlier versions are read as before and are never rewritten, and this version | ||
| reads compressed records whether or not it writes them. That keeps downgrades simple: a node that | ||
| never set `-blockcompression` can be downgraded to any earlier version without a reindex, and once | ||
| a later release enables compression by default, a downgrade to this version needs no reindex | ||
| either. Only a downgrade to a version before this one after compression has been used requires | ||
| `-reindex`, since older versions cannot read the compressed records. | ||
|
|
||
| zstd is an optional build dependency (`--without-zstd`, `NO_ZSTD=1` for depends). A build without | ||
| it stores everything uncompressed, accepts only `-blockcompression=0`, and refuses to start on | ||
| block files written with compression until `-reindex` re-downloads those blocks. | ||
|
|
||
| `contrib/linearize/linearize-data.py` reads compressed records with the `zstandard` Python module | ||
| or Python 3.14 and later, and always writes uncompressed records to the bootstrap file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔎 Supported by static analysis
Script executed:
Repository: dashpay/dash
Length of output: 3043
Script executed:
Repository: dashpay/dash
Length of output: 41282
Script executed:
Repository: dashpay/dash
Length of output: 42029
Correct the
--without-zstdhelp text. The feature compresses block and undo records stored in block files, not masternode lists. Remove “masternode lists” fromconfigure.acand both matching entries indoc/build-unix.md.Suggested fix
Apply the equivalent wording change to both
doc/build-unix.mdentries.Committable suggestion