Skip to content

make-options-docs: don't sort the options XML file#142040

Merged
domenkozar merged 1 commit intoNixOS:masterfrom
pennae:optimize-module-docs
Oct 18, 2021
Merged

make-options-docs: don't sort the options XML file#142040
domenkozar merged 1 commit intoNixOS:masterfrom
pennae:optimize-module-docs

Conversation

@pennae
Copy link
Contributor

@pennae pennae commented Oct 17, 2021

Motivation for this change

eval times for nixos-rebuild are long and getting longer. turns out that about half of that time is spent just in make-option-docs, so optimizing that is quite worthwhile. just sorting the XML file with all option descriptions inside of the docbook build instead of in nix saves about 25% instantiation time.

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 via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.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.

@github-actions github-actions bot added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Oct 17, 2021
@pennae pennae requested review from domenkozar and jtojnar October 17, 2021 23:46
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Oct 17, 2021
@Artturin Artturin requested a review from edolstra October 18, 2021 01:11
@Artturin
Copy link
Member

Nice! How did you discover this?

@pennae
Copy link
Contributor Author

pennae commented Oct 18, 2021

tried to figure out what the most expensive part of the module system is, ran a system instantiation with NIX_COUNT_CALLS=1, discovered that hasPrefix was the most often called function in the entire thing and went digging :D

we need the file itself as a dependency for the docbook build, but we don't need
it to be properly sorted at the nix level. push the sort out to a python script
instead to save eval time. on the machine used to write this `nix-instantiate
<nixos/nixos> -A system` went down from 7.1s to 5.4s and GC heap size decreased
by 50MB (or 70MB max RSS).
@domenkozar
Copy link
Member

@LnL7 warned about this in a7d75ab#commitcomment-27486286

@LnL7
Copy link
Member

LnL7 commented Oct 18, 2021

Something like this is what I suggested back then 🙂 #33898 (comment)

@domenkozar
Copy link
Member

domenkozar commented Oct 18, 2021

We'll soon switch to markdown instead of xml files so we have to do something similar for optionsMDDoc.

But this keeps the current evaluation smaller so let's go!

@domenkozar domenkozar merged commit 8fdc8fe into NixOS:master Oct 18, 2021
@pennae pennae deleted the optimize-module-docs branch November 24, 2021 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants