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

tree-wide: make rust jemalloc-sys use nixpkgs jemalloc build #243324

Merged
merged 2 commits into from
Oct 20, 2023
Merged

tree-wide: make rust jemalloc-sys use nixpkgs jemalloc build #243324

merged 2 commits into from
Oct 20, 2023

Conversation

yu-re-ka
Copy link
Contributor

Description of changes

Addresses #202863

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 11-100 10.rebuild-linux: 11-100 2.status: merge conflict This PR has merge conflicts with the target branch and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Jul 14, 2023
@yu-re-ka yu-re-ka marked this pull request as draft July 14, 2023 12:38
@yu-re-ka
Copy link
Contributor Author

More difficult than I thought because some packages (where the unprefixed_jemalloc_on_supported_platforms feature is enabled) are not allowed to have the _rjem_ prefix depending on the platform.

@tjni
Copy link
Contributor

tjni commented Jul 17, 2023

What's your current thinking on how to address this? It seems hard to do automatically without better ways to override.

@yu-re-ka
Copy link
Contributor Author

yu-re-ka commented Jul 17, 2023

We can create a prefixed (as is currently in this PR) and only-prefixed-on-some-platforms version.
However for the only-prefixed-on-some-platforms version we need to exactly match the list here and hope that it doesn't change too much across versions of the (tikv-)jemallocator crates.

Then choosing the correct version of the hook should be a matter of trial-and-error.

Then another challenge is finding all rust packages that build with jemallocator

@tjni
Copy link
Contributor

tjni commented Jul 17, 2023

This does sound like the best option today.

However for the only-prefixed-on-some-platforms version we need to exactly match the list

Perhaps this can be considered an issue that upstreams would be amenable to fixing, so then our second variant is just the system jemalloc.

Then another challenge is finding all rust packages that build with jemallocator

I think the only way to find these right now is if someone like you encounters a breakage.

@alyssais alyssais added the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 10, 2023
Copy link
Member

@alyssais alyssais left a comment

Choose a reason for hiding this comment

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

The unprefixed variant doesn't seem to be used anywhere — is that still waiting for testing each package to determine which one it needs?

setupHook = writeText "setup-hook.sh" ''
addRustJemalloc () {
if test -f "$1/rust-jemalloc"; then
export JEMALLOC_OVERRIDE="$1/lib/libjemalloc${stdenv.hostPlatform.extensions.library}"
Copy link
Member

Choose a reason for hiding this comment

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

I think we can maybe do

Suggested change
export JEMALLOC_OVERRIDE="$1/lib/libjemalloc${stdenv.hostPlatform.extensions.library}"
export JEMALLOC_OVERRIDE="@out@/lib/libjemalloc${stdenv.hostPlatform.extensions.library}"

and not need the if or the postFixup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed we can. done.

@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 11, 2023
@yu-re-ka yu-re-ka marked this pull request as ready for review October 13, 2023 19:46
@yu-re-ka yu-re-ka merged commit 799fff8 into NixOS:master Oct 20, 2023
20 of 22 checks passed
@hmenke
Copy link
Member

hmenke commented Nov 2, 2023

This broke all Rust static builds that use jemalloc (which is pretty much everything). For example ruff

$ git checkout 799fff889b1e
$ nix-build -A pkgsStatic.ruff # error
$ git checkout HEAD^
$ nix-build -A pkgsStatic.ruff # succeeds

@alyssais
Copy link
Member

alyssais commented Nov 2, 2023

Right, yes. We have two options, then. Make every package only conditionally depend on rust-jemalloc-sys when !stdenv.hostPlatform.isStatic, or set rust-jemalloc-sys to null in that case. @yu-re-ka, any thoughts?

@yu-re-ka yu-re-ka deleted the jemalloc-16k branch November 2, 2023 21:40
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.

5 participants