haskell.nix icon indicating copy to clipboard operation
haskell.nix copied to clipboard

Reduce the number of derivations

Open hamishmack opened this issue 3 years ago • 35 comments
trafficstars

  • Share the default setup executable.
  • Make configFiles and ghc outputs of the component derivation.
  • Use propagatedBuildInputs and pkgsHostTarget for component dependencies.

hamishmack avatar Aug 20 '22 04:08 hamishmack

bors try

hamishmack avatar Aug 20 '22 04:08 hamishmack

try

Build failed:

iohk-bors[bot] avatar Aug 20 '22 06:08 iohk-bors[bot]

bors try

hamishmack avatar Aug 20 '22 13:08 hamishmack

bors try-

hamishmack avatar Aug 20 '22 14:08 hamishmack

bors try

hamishmack avatar Aug 20 '22 14:08 hamishmack

try

Build failed:

iohk-bors[bot] avatar Aug 20 '22 15:08 iohk-bors[bot]

bors try

hamishmack avatar Aug 20 '22 23:08 hamishmack

try

Build failed:

iohk-bors[bot] avatar Aug 21 '22 00:08 iohk-bors[bot]

Use propagatedBuildInputs and pkgsHostTarget for component dependencies.

Is this a good idea? This means that if you pull in our wrapped GHC for any other purposes you'll get all the components pulled in too, right? And does it actually save us derivations? Presumably you still have the same number of derivations, they're just tracked differently?

michaelpj avatar Aug 21 '22 08:08 michaelpj

bors try

hamishmack avatar Aug 21 '22 22:08 hamishmack

try

Build failed:

iohk-bors[bot] avatar Aug 21 '22 23:08 iohk-bors[bot]

Is this a good idea?

The gain I was hoping to get here was reducing the amount of strings concatenation and the overall size of the strings in the component derivations. Currently we currently concat the output paths of the dependencies and put them in configurePhase string. Ultimately I would like to use the same static configure.sh and build.sh for all components, this is a first step towards that.

This means that if you pull in our wrapped GHC for any other purposes you'll get all the components pulled in too, right?

Good point. Although the GHC derivation did not change, executable components do include the propagatedBuildInputs. I'll change it to use regular buildInputs for executable components. I think only the library components need propagatedBuildInputs.

And does it actually save us derivations?

No

Presumably you still have the same number of derivations, they're just tracked differently?

Yes. I am hoping the more standard nix solution may be better optimised.

hamishmack avatar Aug 21 '22 23:08 hamishmack

bors try

hamishmack avatar Aug 22 '22 02:08 hamishmack

try

Build failed:

iohk-bors[bot] avatar Aug 22 '22 03:08 iohk-bors[bot]

Maybe worth doing 1+2 separately since they're maybe less controversial and also less invasive?

michaelpj avatar Aug 22 '22 09:08 michaelpj

2+3 are fairly closely linked. It might be hard to split and merge them. We could probably do 1 on its own (there is a branch with that), but all of these changes require rebuilding all the GHCs on hydra.iohk.io and it would be nice if we only had to do that once.

hamishmack avatar Aug 22 '22 12:08 hamishmack

bors try

hamishmack avatar Aug 29 '22 08:08 hamishmack

try

Timed out.

iohk-bors[bot] avatar Aug 29 '22 11:08 iohk-bors[bot]

bors try

hamishmack avatar Aug 31 '22 10:08 hamishmack

try

Build failed:

iohk-bors[bot] avatar Aug 31 '22 12:08 iohk-bors[bot]

Why not just make each derivation more efficient? If it's several orders of magnitude of difference, maybe, but otherwise, making the derivations more light weight and possibly optimising the daemon seems more efficient to me.

L-as avatar Sep 02 '22 09:09 L-as

Why not just make each derivation more efficient?

How?

hamishmack avatar Sep 02 '22 09:09 hamishmack

Avoiding stdenv is probably a big one.

L-as avatar Sep 02 '22 09:09 L-as

Avoiding stdenv is probably a big one.

Not sure I understand. Can you give and example of something in the haskell.nix code we should be avoiding?

The goal here is to reduce the eval time when no code needs to built. My aim was to reduce the amount and size of the derivations in the hope that eval would be faster over all.

Once this change is merged I was going to look into how much could be saved by move the large configurePhase and buildPhase and installPhase strings into static shell scripts that use env variables as inputs (that is why this change uses pkgsHostTarget environment variable).

hamishmack avatar Sep 02 '22 10:09 hamishmack

bors try

hamishmack avatar Sep 04 '22 12:09 hamishmack

try

Build failed:

iohk-bors[bot] avatar Sep 04 '22 12:09 iohk-bors[bot]

bors try

hamishmack avatar Sep 04 '22 12:09 hamishmack

try

Build failed:

iohk-bors[bot] avatar Sep 04 '22 14:09 iohk-bors[bot]

bors try

hamishmack avatar Sep 05 '22 03:09 hamishmack

try

Build failed:

iohk-bors[bot] avatar Sep 05 '22 03:09 iohk-bors[bot]