Skip to content
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

build: zstd with assembly decompression routines won't build on linux #105568

Closed
jbowens opened this issue Jun 26, 2023 · 11 comments · Fixed by #127208
Closed

build: zstd with assembly decompression routines won't build on linux #105568

jbowens opened this issue Jun 26, 2023 · 11 comments · Fixed by #127208
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-dev-inf

Comments

@jbowens
Copy link
Collaborator

jbowens commented Jun 26, 2023

In cockroachdb/pebble#2668 we upgraded the version of Pebble's dependency on this zstd package. This builds in Pebble's CI across platforms, locally on MacOS and in a Linux gceworker. An attempt to bump the Pebble version of the cockroach repository was made in #105473. While cockroach builds on that branch on MacOS, it fails on linux (both in CI & on a gceworker):

/tmp/rules_go_work-3841712515/cgo/github.com/DataDog/zstd/_x16.o:huf_decompress.c:function HUF_decompress4X1_usingDTable_internal: error: undefined reference to 'HUF_decompress4X1_usingDTable_internal_fast_asm_loop'
/tmp/rules_go_work-3841712515/cgo/github.com/DataDog/zstd/_x16.o:huf_decompress.c:function HUF_decompress4X2_usingDTable_internal: error: undefined reference to 'HUF_decompress4X2_usingDTable_internal_fast_asm_loop'

These symbols appear to be defined here:
https://github.com/DataDog/zstd/blob/ea68dcab66c0fe39989a14c4b6acc520abf80231/huf_decompress_amd64.S#L355
https://github.com/DataDog/zstd/blob/ea68dcab66c0fe39989a14c4b6acc520abf80231/huf_decompress_amd64.S#L99C1-L99C53

However these symbols are marked 'hidden' for ELF targets for an unknown reason:
https://github.com/DataDog/zstd/blob/ea68dcab66c0fe39989a14c4b6acc520abf80231/portability_macros.h#L69-L74

Relevant internal thread.

Jira issue: CRDB-29108

@jbowens jbowens added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-dev-inf labels Jun 26, 2023
@jbowens
Copy link
Collaborator Author

jbowens commented Jun 26, 2023

cc @rickystewart, @bananabrick

jbowens added a commit to jbowens/pebble that referenced this issue Jun 26, 2023
This reverts commit 975fbcb.

The CockroachDB build process is unable to build zstd at v1.5.6 on Linux.
Resolving this issue is tracked in cockroachdb/cockroach#105568.
jbowens added a commit to cockroachdb/pebble that referenced this issue Jun 26, 2023
This reverts commit 975fbcb.

The CockroachDB build process is unable to build zstd at v1.5.6 on Linux.
Resolving this issue is tracked in cockroachdb/cockroach#105568.
@jbowens
Copy link
Collaborator Author

jbowens commented Jun 26, 2023

I reverted the dependency upgrade for now in cockroachdb/pebble#2679.

@pkieltyka
Copy link

hi all -- loving the work on cockroachdb + pebble. We use pebble is many of our production applications with great success. We'd love to see this zstd ticket solved so it can unblock pebble to be use zstd without crashing. I'm putting up a bounty on this ticket, for anyone who solves this ticket by Jan 1, 2024 I will offer $2k USD bounty.

@jbowens
Copy link
Collaborator Author

jbowens commented Mar 1, 2024

@kenliu-crl, @rickystewart do you think we can schedule work on this soon? This may help reduce storage costs of customers and improve TCO if we can unblock use of zstd.

@kenliu-crl
Copy link
Contributor

Hi @jbowens and @itsbilal let's discuss this and see if we can get this planned for the 24.2 release cycle.

@jbowens
Copy link
Collaborator Author

jbowens commented Mar 11, 2024

@kenliu-crl Okay. I'm not sure if this is even large enough to warrant a roadmap item, but I don't know much about the build system at all (:

@jbowens
Copy link
Collaborator Author

jbowens commented Mar 15, 2024

I've staged a rebased version of the Pebble changes here: cockroachdb/pebble#3416.

And here's a cockroach branch attempting to use those Pebble changes: master...jbowens:cockroach:zstd-debug

@jbowens
Copy link
Collaborator Author

jbowens commented Mar 19, 2024

Is there a means to pass C define flags to a dependency? A workaround we can pursue is disabling the assembly routines. This can be done with a minimal patch:

diff -urN a/portability_macros.h b/portability_macros.h
index ecf5453..1413020 100644
--- a/portability_macros.h
+++ b/portability_macros.h
@@ -115,6 +115,8 @@
 #  define ZSTD_ASM_SUPPORTED 0
 #endif

+#define ZSTD_DISABLE_ASM 1
+
 /**
  * Determines whether we should enable assembly for x86-64
  * with BMI2.

but I imagine there's a way to pass it through bazel?

@rickystewart
Copy link
Collaborator

Is there a means to pass C define flags to a dependency?

Yes, we would probably use copts, as in copts = ["-DZSTD_DISABLE_ASM=1"] (docs). That would probably be done as a patch to the dependency (see others in build/patches).

jbowens added a commit to jbowens/cockroach that referenced this issue Mar 20, 2024
Changes:

 * [`7b8b3d5a`](cockroachdb/pebble@7b8b3d5a) *,sstable: upgrade zstd to v1.5.6
 * [`3a7021c5`](cockroachdb/pebble@3a7021c5) db: reuse backings for external ingestions

This commit bumps the zstd dependency as well, working around cockroachdb#105568 by
disabling the assembly routines for now.

Informs cockroachdb#105568.
Release note: none.
Epic: none.
craig bot pushed a commit that referenced this issue Mar 20, 2024
120674: sql: allow procedures to call other procedures r=mgartner a=mgartner

#### sql/logictest: add more tests for UDFs calling UDFs

This commit rearranges some existing tests and adds a few new tests for
UDFs that invoke other UDFs.

Release note: None

#### sql: allow procedures to call other procedures

Fixes #88198

Release note (sql change): Stored procedures can now invoke other
stored procedures via `CALL` statements.


120767: go.mod: bump Pebble to 7b8b3d5a8211 r=RaduBerinde a=jbowens

Changes:

 * [`7b8b3d5a`](cockroachdb/pebble@7b8b3d5a) *,sstable: upgrade zstd to v1.5.6
 * [`3a7021c5`](cockroachdb/pebble@3a7021c5) db: reuse backings for external ingestions

This commit bumps the zstd dependency as well, working around #105568 by disabling the assembly routines for now.

Informs #105568.
Release note: none.
Epic: none.

120776: cli: add support for remote files in debug range-data r=RaduBerinde a=itsbilal

Previously, if a Checkpoint was created due to a storage-level replica corruption, we wouldn't be able to read the checkpoint if it contained any remote (shared or external) files as the pebble instance opened with `debug range-data` would not be started with the relevant RemoteStorageFactory.

This change adds the same SharedStorage/RemoteStorageFactory params as the usual Pebble start in pkg/server/config.go, so that these checkpoints can be opened.

Fixes #119960.

Epic: None.
Release note: None

Co-authored-by: Marcus Gartner <[email protected]>
Co-authored-by: Jackson Owens <[email protected]>
Co-authored-by: Bilal Akhtar <[email protected]>
@jbowens jbowens changed the title build: latest zstd dependency won't build on linux build: zstd with assembly decompression routines won't build on linux Mar 21, 2024
@jbowens
Copy link
Collaborator Author

jbowens commented Mar 21, 2024

Glad we found a workaround for 24.1 as the benefit (#120784) is significant. Repurposing this issue to be specifically enabling the use of zstd's assembly decompression routines which likely provide a small performance edge on x86 over the C routines we're using now

rharding6373 pushed a commit to rharding6373/cockroach that referenced this issue Mar 21, 2024
Changes:

 * [`7b8b3d5a`](cockroachdb/pebble@7b8b3d5a) *,sstable: upgrade zstd to v1.5.6
 * [`3a7021c5`](cockroachdb/pebble@3a7021c5) db: reuse backings for external ingestions

This commit bumps the zstd dependency as well, working around cockroachdb#105568 by
disabling the assembly routines for now.

Informs cockroachdb#105568.
Release note: none.
Epic: none.
craig bot pushed a commit that referenced this issue Mar 21, 2024
120784: storage: add storage.sstable.compression_algorithm cluster setting r=jbowens a=jbowens

Introduce a new cluster setting that allows the operator to configure the compression algorithm used when compressing sstable blocks. This allows operators to opt into use of zstd (as opposed to the previous setting of snappy). ZSTD typically achieves better compression ratios than snappy, and operators may find that they can achieve higher node densities through enabling zstd. Future releases may change the default compression algorithm.

In a side-by-side comparison of a 10000-warehouse tpcc import, the zstd cluster achieved a higher import speed of 146 MiB/s versus snappy's 135 MiB/s. The zstd cluster's physical database size was significantly less (~30%).

<img width="976" alt="Screenshot 2024-03-20 at 3 07 13 PM" src="https://github.com/cockroachdb/cockroach/assets/867352/a92a4d6a-135d-4e5c-9b38-794123e8fcec">
<img width="983" alt="Screenshot 2024-03-20 at 3 06 49 PM" src="https://github.com/cockroachdb/cockroach/assets/867352/275f9ecf-1783-4b7b-8159-a734a6275dea">

Informs #105568.
Epic: none
Release note (ops change): Add `storage.sstable.compression_algorithm` cluster setting that configures the compression algorithm to use when compressing sstable blocks.

Co-authored-by: Jackson Owens <[email protected]>
@rickystewart rickystewart self-assigned this Jun 25, 2024
@nicktrav
Copy link
Collaborator

nicktrav commented Jul 1, 2024

Linking this as a blocker for #123953.

rickystewart added a commit to rickystewart/rules_go that referenced this issue Jul 15, 2024
* Fix the conditional and comments to bring them closer to upstream.
  The next time we upgrade `rules_go`, we can squash this with the
  previous commit `0e7e4e31aa49f1afbb402fbb4895f38bc702c88c`.
* Make sure to pass in `sSrcs` to `cgo2()`.

Part of: cockroachdb/cockroach#105568
rickystewart added a commit to cockroachdb/rules_go that referenced this issue Jul 15, 2024
* Fix the conditional and comments to bring them closer to upstream.
  The next time we upgrade `rules_go`, we can squash this with the
  previous commit `0e7e4e31aa49f1afbb402fbb4895f38bc702c88c`.
* Make sure to pass in `sSrcs` to `cgo2()`.

Part of: cockroachdb/cockroach#105568
craig bot pushed a commit that referenced this issue Jul 16, 2024
127208: DEPS.bzl: update `rules_go` and enable assembly routines for zstd r=rickystewart a=rickystewart

There was an issue with one of our patches to `rules_go` that was fixed in cockroachdb/rules_go#21. We pull in that change and additionally remove our patch that disabled the assembly routines.

Closes: #105568
Epic: CRDB-17171
Release note: None

Co-authored-by: Ricky Stewart <[email protected]>
@craig craig bot closed this as completed in 048695a Jul 16, 2024
blathers-crl bot pushed a commit that referenced this issue Jul 16, 2024
There was an issue with one of our patches to `rules_go` that was fixed
in cockroachdb/rules_go#21. We pull in that change and additionally
remove our patch that disabled the assembly routines.

Closes: #105568
Epic: CRDB-17171
Release note: None
blathers-crl bot pushed a commit that referenced this issue Jul 16, 2024
There was an issue with one of our patches to `rules_go` that was fixed
in cockroachdb/rules_go#21. We pull in that change and additionally
remove our patch that disabled the assembly routines.

Closes: #105568
Epic: CRDB-17171
Release note: None
rail pushed a commit to rail/rules_go that referenced this issue Jul 25, 2024
…hdb#21)

* Fix the conditional and comments to bring them closer to upstream.
  The next time we upgrade `rules_go`, we can squash this with the
  previous commit `0e7e4e31aa49f1afbb402fbb4895f38bc702c88c`.
* Make sure to pass in `sSrcs` to `cgo2()`.

Part of: cockroachdb/cockroach#105568
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-dev-inf
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants