Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Preliminary nofib rule #599

Merged
merged 5 commits into from
May 17, 2018
Merged

Preliminary nofib rule #599

merged 5 commits into from
May 17, 2018

Conversation

alpmestan
Copy link
Collaborator

This doesn't yet capture stdout/stderr (nor does it clean or boot, even though I think & hope that the latter is done automatically), so we can't really use nofib-analyse yet (see the nofib trac page).

Still a WIP. Meant to address #594.

@snowleopard Any guidance for the output capture bit? I would have thought the code in Nofib.hs would accomplish what I want (well, eventually I'll want stdout and stderr in the same file), but I can't see any nofib.stdout/nofib.stderr under my build root.

@alpmestan alpmestan mentioned this pull request May 11, 2018
@snowleopard
Copy link
Owner

snowleopard commented May 12, 2018

@alpmestan Thanks!

Perhaps you can capture stdout and stderr directly without intermediate files as in the examples below?

https://hackage.haskell.org/package/shake-0.16.4/docs/Development-Shake.html#v:cmd
https://hackage.haskell.org/package/shake-0.16.4/docs/Development-Shake.html#v:command

nofibRules = do
"nofib" ~> do
needNofibBuilders
makePath <- builderPath (Make "")
Copy link
Owner

Choose a reason for hiding this comment

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

I guess Make "nofib" would be a bit more appropriate (but equivalent).

@alpmestan
Copy link
Collaborator Author

Perhaps you can capture stdout and stderr directly without intermediate files as in the examples below?

So you mean something like:

(Stdout out, Stderr err) <- cmd ...

?

@snowleopard
Copy link
Owner

@alpmestan Yes! This might require introducing a new buildWith primitive, but it will be generally useful.

@alpmestan
Copy link
Collaborator Author

Oh, there even is an Stdouterr newtype with a suitable CmdResult instance. This would mirror the first part of the following command:

$ make 2>&1 | tee nofib-log

that is required to run nofib (see here).

I can then write the resulting bytestring to a file under <build root> myself and achieve what I want. The entire process for running nofib however is:

$ cd nofib
$ make clean
$ make boot                  # Generates Makefile dependencies
$ make 2>&1 | tee nofib-log  # Compiles and runs benchmarks one by one

So I suppose I would be better off with a dedicated builder for nofib that runs all those commands, instead of having to special-case on Make "nofib". Getting this whole set of commands to leave the source tree untouched and to put everything under the build root is not something I'm going to look into right now. :-)

@snowleopard
Copy link
Owner

@alpmestan Sounds good :) Please ping me when you think this PR is ready.

@alpmestan
Copy link
Collaborator Author

alpmestan commented May 15, 2018

@snowleopard This PR in its current state lets me run nofib to completion with ./build.sh -j4 --build-flavour=_foo nofib from a booted & configured source tree. nofib log available here.

CI seems to be failing for an unrelated reason (and fails with the same error in the validation related PR). This patch is ready for review & possibly landing if you're satisfied.

-- by running the nofib suite and capturing
-- the relevant output.
root -/- nofibLogFile %> \fp -> do
needNofibDeps
Copy link
Owner

@snowleopard snowleopard May 16, 2018

Choose a reason for hiding this comment

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

I'm confused: why don't you simply execute all required commands here? What is the benefit of having a separate builder?

In the rest of Hadrian, we use builders primarily to have a unified way to track builder-specific command line arguments. But you are not using Args here, so it seems that defining a new builder is not necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I'll simplify this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@snowleopard
Copy link
Owner

@alpmestan The PR looks good to me now -- do you think it is ready to be merged?

@alpmestan
Copy link
Collaborator Author

Yes, I'm happy with this patch as it is now. Merge when you want :-)

@snowleopard snowleopard merged commit d6c4e04 into snowleopard:master May 17, 2018
@snowleopard
Copy link
Owner

Done, thank you :-)

@alpmestan alpmestan deleted the alp/nofib branch May 17, 2018 13:23
@snowleopard
Copy link
Owner

@alpmestan Wait, it looks like this PR introduced recursive rules -- could you please have a look and fix?

@snowleopard
Copy link
Owner

Once again, we are hit by now working CI -- we should give the highest priority to fixing it!

@alpmestan
Copy link
Collaborator Author

@snowleopard I think I was seeing recursive rule errors on other PRs before I made this one, and I'm definitely not seeing anything like this locally. Could you give me commands + git commit for reproducing the issue?

@snowleopard
Copy link
Owner

@alpmestan Well, both AppVeyor and Travis bots fail in the same way, and I think this is the first PR where this happened, but I may be mistaken, of course. I think it is sufficient to run build selftest to reproduce (but I won't have a chance to try on my machine until evening).

@@ -9,8 +10,16 @@ makeBuilderArgs = do
threads <- shakeThreads <$> expr getShakeOptions
gmpPath <- expr gmpBuildPath
libffiPath <- expr libffiBuildPath
ghcPath <- expr $
(-/-) <$> topDirectory <*> builderPath (Ghc CompileHs Stage2)
Copy link
Owner

Choose a reason for hiding this comment

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

@alpmestan This could be the reason? You might want to move this into the nofib subexpression.

Copy link
Owner

Choose a reason for hiding this comment

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

Here is the error, which mentions ghc-source-path:

Build system error - indirect recursion detected:
  Key value 1:  OracleQ (KeyValue ("hadrian/cfg/system.config","host-os"))
  Key value 2:  hadrian/cfg/system.config
  Key value 3:  hadrian/cfg/system.config settings mk/config.h compiler/ghc.cabal
  Key value 4:  OracleQ (KeyValue ("hadrian/cfg/system.config","ghc-source-path"))
Rules may not be recursive

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't even need this anymore. Let me try getting rid of the changes to this file altogether.

@snowleopard
Copy link
Owner

@alpmestan To be more precise, you should try build -c selftest to reproduce.

@alpmestan
Copy link
Collaborator Author

I managed to reproduce with build -c selftest. The patch at #606 makes the problem go away for me.

chitrak7 pushed a commit to chitrak7/hadrian that referenced this pull request May 18, 2018
* first draft of a nofib rule

* address some of Andrey's feedback

* refactor nofib into a proper Builder, now runs but one of the programs fails

* more subtle error handling, docs

* get rid of RunNofib builder, invoke commands directly
chitrak7 pushed a commit to chitrak7/hadrian that referenced this pull request Jun 4, 2018
* first draft of a nofib rule

* address some of Andrey's feedback

* refactor nofib into a proper Builder, now runs but one of the programs fails

* more subtle error handling, docs

* get rid of RunNofib builder, invoke commands directly
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants