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

ocaml: enable parallel building #142723

Closed
wants to merge 1 commit into from
Closed

Conversation

trofi
Copy link
Contributor

@trofi trofi commented Oct 24, 2021

Enable parallel building for ocaml-4.06 and above. tested as:

$ nix build -f. ocaml-ng.ocamlPackages_{4_{00_1,01_0,02,03,04,05,06,07,08,09,10,11,12,13},latest}.ocaml --keep-going --rebuild

ocaml build system supports parallel building, but but for multiple
top-level targets at the same time as it usually spawns subprocess
$(MAKE) that occasionally conflict with one another. To work it around
we use tiny Makefile with a single rule that calls top-level targets
sequentially as makefile calls:

nixpkgs_world_bootstrap_world_opt:
   $(MAKE) world
   $(MAKE) bootstrap
   $(MAKE) world.opt

On a 16-core machine ocaml-4.12 build speeds up from 6m55s to 1m35s.

Releases 4_00_1, 4_01_0, 4_04 and 4_05 still have some race in them.
Thus this change enables parallel builds only for ocaml-4.06 and above.

Enable parallel building for ocaml-4.06 and above. tested as:

    $ nix build -f. ocaml-ng.ocamlPackages_{4_{00_1,01_0,02,03,04,05,06,07,08,09,10,11,12,13},latest}.ocaml --keep-going --rebuild

ocaml build system supports parallel building, but but for multiple
top-level targets at the same time as it usually spawns subprocess
$(MAKE) that occasionally conflict with one another. To work it around
we use tiny Makefile with a single rule that calls top-level targets
sequentially as makefile calls:

    nixpkgs_world_bootstrap_world_opt:
       $(MAKE) world
       $(MAKE) bootstrap
       $(MAKE) world.opt

On a 16-core machine ocaml-4.12 build speeds up from 6m55s to 1m35s.

Releases 4_00_1, 4_01_0, 4_04 and 4_05 still have some race in them.
Thus this change enables parallel builds only for ocaml-4.06 and above.
@risicle
Copy link
Contributor

risicle commented Oct 24, 2021

ocaml 4.12.0 builds successfully for me on nixos x86_64 and macos 10.15. Can't easily say whether it actually has any effect on macos though.

@symphorien
Copy link
Member

cc @vbgl

@vbgl
Copy link
Contributor

vbgl commented Nov 8, 2021

Are you sure you want to change the derivation for OCaml 4.00.1?

@trofi
Copy link
Contributor Author

trofi commented Nov 8, 2021

When/if enableParallelBuilding = true; becomes the default then .nix file will break. Thus yes, I'm pretty confident we need to change 4.00.1.nix to at least specify enableParallelBuilding = false;.

So far it does it by having a verbatim copy of generic.nix to ease syncing changes between the two.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/635

Copy link
Member

@symphorien symphorien left a comment

Choose a reason for hiding this comment

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

Looks good to me, and the added complexity seems warranted.

I will merge in a few days if nobody objects until then.

@vbgl
Copy link
Contributor

vbgl commented Dec 9, 2021

IMHO, the change made to the derivation for OCaml 4.00 makes no sense.

@trofi trofi closed this Dec 9, 2021
@trofi trofi deleted the parallel-ocaml branch December 9, 2021 15:14
@symphorien symphorien mentioned this pull request Dec 10, 2021
13 tasks
@symphorien
Copy link
Member

reopened without the ocaml 4.00 change as #150128

symphorien pushed a commit to symphorien/nixpkgs that referenced this pull request Feb 27, 2022
Enable parallel building for ocaml-4.08 and above. tested as:

    $ nix build -f. ocaml-ng.ocamlPackages_{4_{00_1,01_0,02,03,04,05,06,07,08,09,10,11,12,13},latest}.ocaml --keep-going

ocaml build system supports parallel building, but but for multiple
top-level targets at the same time as it usually spawns subprocess
$(MAKE) that occasionally conflict with one another. To work it around
we use tiny Makefile with a single rule that calls top-level targets
sequentially as makefile calls:

    nixpkgs_world_bootstrap_world_opt:
       $(MAKE) world
       $(MAKE) bootstrap
       $(MAKE) world.opt

On a 16-core machine ocaml-4.12 build speeds up from 6m55s to 1m35s.

Releases 4_00_1, 4_01_0, 4_04 and 4_05 still have some race in them.
Thus this change enables parallel builds only for ocaml-4.06 and above.

Adapted from NixOS#142723

upstreams's CI tests the parallel makefile: ocaml/ocaml#10235 (comment)
The limit was chosen to be 4.08 because it was released in 2019, not too
long before the above link.
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