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

gnugrep: enable parallel build and tests #236229

Merged
merged 3 commits into from
Jun 11, 2023
Merged

Conversation

trofi
Copy link
Contributor

@trofi trofi commented Jun 6, 2023

On a 16-core system number changes are:

  • before: 1m34s
  • after: 39s

2.5x speedup. If ./configure phase was faster the change would be even more substantial.

Description of changes
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.

On a 16-core system number changes are:

- before: 1m34s
- after: 39s

2.5x speedup. If ./configure phase was faster the change would be even
more substantial.
@dasJ
Copy link
Member

dasJ commented Jun 6, 2023

Since you are already touching the package, could you pick this darwin patch as well so Hydra is more likely to succeed with the rebuild?

@trofi
Copy link
Contributor Author

trofi commented Jun 6, 2023

Since you are already touching the package, could you pick this darwin patch as well so Hydra is more likely to succeed with the rebuild?

Sounds good! Will take me a few hours.

@trofi
Copy link
Contributor Author

trofi commented Jun 6, 2023

Added gnugrep: disable gnulib tests on x86_64-darwin as well. It's a slightly different but equivalent patch that uses equivalent helpers:

--- a/pkgs/tools/text/gnugrep/default.nix
+++ b/pkgs/tools/text/gnugrep/default.nix
@@ -19,2 +19,4 @@ stdenv.mkDerivation {
-  # Some gnulib tests fail on Musl: https://github.com/NixOS/nixpkgs/pull/228714
-  postPatch = if stdenv.hostPlatform.isMusl then ''
+  # Some gnulib tests fail
+  # - on Musl: https://github.com/NixOS/nixpkgs/pull/228714
+  # - on x86_64-darwin: https://github.com/NixOS/nixpkgs/pull/228714#issuecomment-1576826330
+  postPatch = if stdenv.hostPlatform.isMusl || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) then ''

Tested eval as:

$ nix repl . --argstr system x86_64-darwin
nix-repl> gnugrep.postPatch
"sed -i 's:gnulib-tests::g' Makefile.in\n"

Looks expected.

@reckenrode
Copy link
Contributor

gnugrep no longer hangs with the Darwin patch, but I get a test failure (Rosetta 2, macOS 13.4).

FAIL: stack-overflow
====================

./stack-overflow: line 31: 23183 Abort trap: 6           grep -E -f in > out 2> err
./stack-overflow: line 31: 23195 Abort trap: 6           grep -E -f in > out 2> err
./stack-overflow: line 31: 23208 Abort trap: 6           grep -E -f in > out 2> err
./stack-overflow: line 31: 23220 Abort trap: 6           grep -E -f in > out 2> err
./stack-overflow: line 31: 23233 Abort trap: 6           grep -E -f in > out 2> err
./stack-overflow: line 31: 23245 Abort trap: 6           grep -E -f in > out 2> err
./stack-overflow: line 31: 23257 Abort trap: 6           grep -E -f in > out 2> err
./stack-overflow: line 31: 23270 Abort trap: 6           grep -E -f in > out 2> err
./stack-overflow: line 31: 23285 Abort trap: 6           grep -E -f in > out 2> err
./stack-overflow: line 31: 23300 Abort trap: 6           grep -E -f in > out 2> err
./stack-overflow: line 31: 23325 Abort trap: 6           grep -E -f in > out 2> err
stack-overflow: failed test: grep never printed "stack overflow"
FAIL stack-overflow (exit status: 1)

I modified the test script to cat the actual contents of err. It doesn’t look like this test plays very nicely with Rosetta 2. This is what it shows:

rosetta error: unexpectedly need to EmulateForward on a synchronous exception x86_rip=0x4303486096 arm_pc=0x4303949136 num_insts=6 inst_index=4 x86 instruction bytes: 0x6215344901283465301 0x17041981987679720769

@trofi
Copy link
Contributor Author

trofi commented Jun 7, 2023

Looks like an emulator deficiency. Is it generally able to run testsuites of most other programs?

@reckenrode
Copy link
Contributor

reckenrode commented Jun 7, 2023

Looks like an emulator deficiency. Is it generally able to run testsuites of most other programs?

Normally, yes.

This particular test creates a pathological file with a million left-parens then tries to grep it. The test wants grep to crash, but it doesn’t crash with the expected error message (grep: stack overflow), so the test fails.

If you perform the test manually (create the file, try to grep it), it does crash in the expected way. There’s something about the test environment it sets up that causes the Rosetta 2 error.

@trofi
Copy link
Contributor Author

trofi commented Jun 7, 2023

Aha, that makes sense. I wonder if gnugrep's failure something non-trivial (like initial environment size) or a sandbox configuration bug (if darwin implements sandbox) where we don't pass through enough into the build environment for emulator to just work.

@reckenrode
Copy link
Contributor

reckenrode commented Jun 7, 2023

Darwin support sandboxing, which normally works with Rosetta 2. However, while I normally have the sandbox enabled, it was disabled when I captured the output with the Rosetta 2 error.

When running on Rosetta 2 emulator (x86_64-darwin biaries executed on
aarch64-darwin) `stack-overflow` test fails as:

    rosetta error: unexpectedly need to EmulateForward on a synchronous exception x86_rip=0x4303486096 arm_pc=0x4303949136 num_insts=6 inst_index=4 x86 instruction bytes: 0x6215344901283465301 0x17041981987679720769
@trofi
Copy link
Contributor Author

trofi commented Jun 7, 2023

Added gnugrep: disable tests x86_64-darwin to disable tests on x86_64-darwin as:

--- a/pkgs/tools/text/gnugrep/default.nix
+++ b/pkgs/tools/text/gnugrep/default.nix
@@ -33 +33,2 @@ stdenv.mkDerivation {
-  doCheck = !stdenv.isCygwin && !stdenv.isFreeBSD;
+  # x86_64-darwin: fails 'stack-overflow' tests on Rosetta 2 emulator
+  doCheck = !stdenv.isCygwin && !stdenv.isFreeBSD && !(stdenv.isDarwin && stdenv.hostPlatform.isx86_64);

@trofi
Copy link
Contributor Author

trofi commented Jun 11, 2023

Let's declare it good enough for staging.

@trofi trofi merged commit a4d88ee into NixOS:staging Jun 11, 2023
@trofi trofi deleted the gnugrep-parallel branch June 11, 2023 17:03
reckenrode added a commit to reckenrode/nixpkgs that referenced this pull request Jul 3, 2023
The test-c-stack tests hang on x86_64-darwin when they are run under
Rosetta 2. Disabling these tests allows the rest of the tests to run
successfully on that platform.

This is a similar to the issue that affected gnugrep (NixOS#236229).
reckenrode added a commit to reckenrode/nixpkgs that referenced this pull request Jul 3, 2023
The test-c-stack tests hang on x86_64-darwin when they are run under
Rosetta 2. Disabling these tests allows the rest of the tests to run
successfully on that platform.

This is a similar to the issue that affected gnugrep (NixOS#236229).
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