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

stack bench fails to run gauge benchmarks with Nix mode #4095

Closed
qrilka opened this issue Jun 17, 2018 · 2 comments
Closed

stack bench fails to run gauge benchmarks with Nix mode #4095

qrilka opened this issue Jun 17, 2018 · 2 comments

Comments

@qrilka
Copy link
Contributor

qrilka commented Jun 17, 2018

Steps to reproduce

Run stack bench --nix on https://github.com/qrilka/gauge-test

Expected

Proper benchmark output as e.g. with stack bench

Actual

Benchmark run fails:


$ stack build --bench
gauge-test-0.1.0.0: benchmarks
Running 1 benchmarks...
Benchmark bench: RUNNING...
benchmarked trivial/trivial
time                 6.356 ns   (6.331 ns .. 6.386 ns)
bench: <stdout>: hPutChar: invalid argument (invalid character)
                     1.000 RBenchmark bench: ERROR

--  While building custom Setup.hs for package gauge-test-0.1.0.0 using:
      /home/kirill/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-2.0.1.0 bench bench
    Process exited with code: ExitFailure 1

Stack version

$ stack --version 
Version 1.6.5 x86_64
Compiled with:
- Cabal-2.0.1.0
- Glob-0.9.1
...

Method of installation

Tested with 1.6.5 shipped with NixOS, 1.6.1 on Gentoo, 1.7.1 on NixOS build from the sources

@snoyberg
Copy link
Contributor

This is probably unrelated to Stack itself. Stack's Nix integration uses pure mode IIRC, which means that env vars like LANG won't be passed through, resulting in the program being unable to output non-ASCII characters. Recommendations:

  • Try running the executable directly instead of through stack and see what happens. It'll be located inside .stack-work somewhere
  • Try turning off pure mode for Nix. I don't know the configuration option for that offhand
  • Report the issue to the gauge issue tracker. It would be good if it was more discerning about when to use non-ASCII characters, or at least use a handle encoding that was forgiving

Potential "fix" inside Stack I can think of is telling Nix to always pass along appropriate language env vars, though I know almost nothing about Nix or the Nix integration in Stack.

@qrilka
Copy link
Contributor Author

qrilka commented Jun 18, 2018

Thanks @snoyberg
I wasn't 100% sure what tracker that to post to and probably should have dug deeper into what's going on.
And your hypothesis seem to be correct:

$ stack --nix --no-nix-pure bench
gauge-test-0.1.0.0: benchmarks
Running 1 benchmarks...
Benchmark bench: RUNNING...
benchmarked trivial/trivial
time                 8.797 ns   (8.738 ns .. 8.860 ns)
                     0.999 R²   (0.999 R² .. 1.000 R²)
mean                 8.900 ns   (8.855 ns .. 8.957 ns)
std dev              171.0 ps   (130.2 ps .. 225.3 ps)

Benchmark bench: FINISH

So it looks like the problem is about "²", e.g.

$ stack --nix bench --ba="-s"
gauge-test-0.1.0.0: benchmarks
Running 1 benchmarks...
Benchmark bench: RUNNING...
trivial/trivial                          mean 8.862 ns  ( +- 101.9 ps  )
Benchmark bench: FINISH

I'll try to look on how to resolve this either on gauge or stack side

@dbaynard dbaynard changed the title stack bench fais to run gauge benchmarks with Nix mode stack bench fails to run gauge benchmarks with Nix mode Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants