Skip to content

zlib-api: new virtual with zlib/zlib-ng as providers#37372

Merged
haampie merged 10 commits intospack:developfrom
haampie:fix/zlib-api-virtual
Aug 9, 2023
Merged

zlib-api: new virtual with zlib/zlib-ng as providers#37372
haampie merged 10 commits intospack:developfrom
haampie:fix/zlib-api-virtual

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented May 2, 2023

Create a new virtual zlib-api and have zlib / zlib-ng as providers.

zlib remains the default provider, maybe in the future we can swap it for zlib-ng to save some CPU cycles across the globe...

My PR zlib-ng/zlib-ng#1546 to improve the zlib-ng build system was merged upstream and included here as a patch, that's why this PR has more + than -; the package changes are mostly one-liners replacing zlib with zlib-api.

@haampie
Copy link
Copy Markdown
Member Author

haampie commented May 2, 2023

Comparing python +opimizations ^zlib-ng against system Python on macOS Ventura to create a compressed tarball of a folder with 250MB of stuff:

zlib-ng version: 2.92s
zlib version: 5.89s

So, 2x faster 🙃

And Spack's tar (based on pigz w/ zlib-ng) vs system tar (gzip w/ zlib) on a macbook air m1:

0.649s
8.661s

13x faster... not bad. (this is both threaded and has better single-threaded perf thanks to zlib-ng)

@haampie haampie force-pushed the fix/zlib-api-virtual branch from cb4b2b7 to 9221271 Compare May 16, 2023 09:11
@haampie haampie force-pushed the fix/zlib-api-virtual branch 2 times, most recently from 1fd7a01 to c7f4779 Compare July 23, 2023 07:14
@haampie
Copy link
Copy Markdown
Member Author

haampie commented Jul 23, 2023

gdal is the only package that needed something extra to fix the build: ENABLE_DEFLATE64=OFF This is because it uses a vendored libdeflate that seems to use zlib-specific stuff (which they also vendor). Solution is probably to use external libdeflate, also note that they use deflate because it's faster than zlib, but maybe it's slower than zlib-ng?

zlib-ng v2.1.3 has some weird rpath issues (zlib-ng/zlib-ng#1523) should be fixable in a next release

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Jul 24, 2023

  • Created a patch upstream for darwin and included it here.

  • Added a clarifying comment to the GDAL package.

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Jul 24, 2023

CI is green after building 1000s of packages, so I think this PR is good to go after switching back to zlib as the default zlib-api.

https://gitlab.spack.io/spack/spack/-/pipelines/452853

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Jul 24, 2023

Sigh. It's going to be building 1000s of packages again, because the zlib package hash has changed now that it provides zlib-api 😆

@wdconinc
Copy link
Copy Markdown
Contributor

wdconinc commented Aug 2, 2023

Are we potentially adding regressions by replacing depends_on("[email protected]:") with depends_on("zlib-api")? Is it potentially safer, or at least more conservative, to leave those explicit versions in place, or to use an additional depends_on("[email protected]:", when="^zlib")?

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Aug 3, 2023

Thanks @wdconinc! I've revived the zlib lowerbounds

@haampie haampie force-pushed the fix/zlib-api-virtual branch from 1e5d00f to 3052fbe Compare August 8, 2023 13:24
@adamjstewart
Copy link
Copy Markdown
Member

Only concern is the inability to specify which version of zlib is required. Does zlib-ng have a known compatibility mapping? Would be nice if we could specify which versions of zlib-api are provided by each version of zlib/zlib-ng.

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Aug 8, 2023

I agree with that, but I think zlib follows https://www.hyrumslaw.com/; it doesn't have a clear public API, and some people mess with accidentally exposed internals :p I think the easiest way to fix those issues is on a per package basis, so e.g. depends_on("[email protected]:", when="^zlib-ng") instead of adding provides("zlib-api@...") to zlib and zlib-ng.

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Aug 8, 2023

@spackbot rerun pipeline

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Aug 8, 2023

I've started that pipeline for you!

@haampie haampie force-pushed the fix/zlib-api-virtual branch from 5ddfa19 to 4b29372 Compare August 9, 2023 10:29
Copy link
Copy Markdown
Member

@alalazo alalazo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked all the commits, though in the first one I just checked the core files and zlib + zlib-ng packages. This LGTM. We can make zlib-ng the default in a following PR.

@haampie haampie enabled auto-merge (squash) August 9, 2023 12:49
@haampie haampie merged commit e51748e into spack:develop Aug 9, 2023
@G-071 G-071 mentioned this pull request Aug 10, 2023
tgamblin pushed a commit that referenced this pull request Aug 17, 2023
In the HPC package manager, we want the fastest `zlib`  implementation by default.  `zlib-ng` is up to 4x faster than stock `zlib`, and it can do things like take advantage of AVX-512 instructions.  This PR makes `zlib-ng` the default `zlib-api` provider (`zlib-api` was introduced earlier, in #37372).

As far as I can see, the only issues you can encounter are:

1. Build issues with packages that heavily rely on `zlib` internals. In Gitlab CI only one out of hundreds of packages had that issue (it extended zlib with deflate stuff, and used its own copy of zlib sources).
2. Packages that like to detect `zlib-ng` separately and rely on `zlib-ng` internals. The only issue I've found with this among the hundreds of packages built in CI is `perl` trying to report more specific zlib-ng version details, and relied on some internals that got refactored. But yeah... that warrants a patch / conflict and is nothing special.

At runtime, you cannot really have any issues, given that zlib and zlib-ng export the exact same symbols (and zlib-ng tests this in their CI).

You can't really have issues with externals when using zlib-ng either. The only type of issue is when system zlib is rather new, and not marked as external; if another external uses new symbols, and Spack builds an older zlib/zlib-ng, then the external might not find the new symbols. But this is a configuration issue, and it's not an issue caused by zlib-ng, as the same would happen with older Spack zlib.

* zlib-api: use zlib-ng +compat by default
* make a trivial change to zlib-ng to trigger a rebuild
* add `haampie` as maintainer
mpokorny pushed a commit to mpokorny/spack that referenced this pull request Sep 18, 2023
Introduces a new virtual zlib-api, which replaces zlib in most packages.

This allows users to switch to zlib-ng by default for better performance.
mpokorny pushed a commit to mpokorny/spack that referenced this pull request Sep 18, 2023
In the HPC package manager, we want the fastest `zlib`  implementation by default.  `zlib-ng` is up to 4x faster than stock `zlib`, and it can do things like take advantage of AVX-512 instructions.  This PR makes `zlib-ng` the default `zlib-api` provider (`zlib-api` was introduced earlier, in spack#37372).

As far as I can see, the only issues you can encounter are:

1. Build issues with packages that heavily rely on `zlib` internals. In Gitlab CI only one out of hundreds of packages had that issue (it extended zlib with deflate stuff, and used its own copy of zlib sources).
2. Packages that like to detect `zlib-ng` separately and rely on `zlib-ng` internals. The only issue I've found with this among the hundreds of packages built in CI is `perl` trying to report more specific zlib-ng version details, and relied on some internals that got refactored. But yeah... that warrants a patch / conflict and is nothing special.

At runtime, you cannot really have any issues, given that zlib and zlib-ng export the exact same symbols (and zlib-ng tests this in their CI).

You can't really have issues with externals when using zlib-ng either. The only type of issue is when system zlib is rather new, and not marked as external; if another external uses new symbols, and Spack builds an older zlib/zlib-ng, then the external might not find the new symbols. But this is a configuration issue, and it's not an issue caused by zlib-ng, as the same would happen with older Spack zlib.

* zlib-api: use zlib-ng +compat by default
* make a trivial change to zlib-ng to trigger a rebuild
* add `haampie` as maintainer
@haampie haampie deleted the fix/zlib-api-virtual branch November 1, 2023 15:41
JaroslavHron added a commit to JaroslavHron/spack that referenced this pull request Aug 1, 2024
After zlib -> zlib-api change (spack#37372) petsc is not including the zlib. This updates the spack-lib -> petsc-lib mapping.
JaroslavHron added a commit to JaroslavHron/spack that referenced this pull request Aug 1, 2024
After zlib -> zlib-api change (spack#37372) petsc is not including the zlib. This updates the spack-lib -> petsc-lib mapping.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants