-
-
Couldn't load subscription status.
- Fork 1.7k
ci: Add build profiling job #13510
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
ci: Add build profiling job #13510
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| { | ||
| nixFlake ? builtins.getFlake ("git+file://" + toString ../../..), | ||
| system ? builtins.currentSystem, | ||
| pkgs ? nixFlake.inputs.nixpkgs.legacyPackages.${system}, | ||
| }: | ||
|
|
||
| let | ||
| inherit (pkgs) lib; | ||
|
|
||
| nixComponentsInstrumented = | ||
| (nixFlake.lib.makeComponents { | ||
| inherit pkgs; | ||
| getStdenv = p: p.clangStdenv; | ||
| }).overrideScope | ||
| ( | ||
| _: _: { | ||
| mesonComponentOverrides = finalAttrs: prevAttrs: { | ||
| outputs = (prevAttrs.outputs or [ "out" ]) ++ [ "buildprofile" ]; | ||
| nativeBuildInputs = [ pkgs.clangbuildanalyzer ] ++ prevAttrs.nativeBuildInputs or [ ]; | ||
| __impure = true; | ||
|
|
||
| env = { | ||
| CFLAGS = "-ftime-trace"; | ||
| CXXFLAGS = "-ftime-trace"; | ||
| }; | ||
|
|
||
| preBuild = '' | ||
| ClangBuildAnalyzer --start $PWD | ||
| ''; | ||
|
|
||
| postBuild = '' | ||
| ClangBuildAnalyzer --stop $PWD $buildprofile | ||
| ''; | ||
| }; | ||
| } | ||
| ); | ||
|
|
||
| componentsToProfile = { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should come up with something a bit nicer than hardcoding lists like this over and over, but that'd be a separate task. |
||
| "nix-util" = { }; | ||
| "nix-util-c" = { }; | ||
| "nix-util-test-support" = { }; | ||
| "nix-util-tests" = { }; | ||
| "nix-store" = { }; | ||
| "nix-store-c" = { }; | ||
| "nix-store-test-support" = { }; | ||
| "nix-store-tests" = { }; | ||
| "nix-fetchers" = { }; | ||
| "nix-fetchers-c" = { }; | ||
| "nix-fetchers-tests" = { }; | ||
| "nix-expr" = { }; | ||
| "nix-expr-c" = { }; | ||
| "nix-expr-test-support" = { }; | ||
| "nix-expr-tests" = { }; | ||
| "nix-flake" = { }; | ||
| "nix-flake-c" = { }; | ||
| "nix-flake-tests" = { }; | ||
| "nix-main" = { }; | ||
| "nix-main-c" = { }; | ||
| "nix-cmd" = { }; | ||
| "nix-cli" = { }; | ||
| }; | ||
|
|
||
| componentDerivationsToProfile = builtins.intersectAttrs componentsToProfile nixComponentsInstrumented; | ||
| componentBuildProfiles = lib.mapAttrs ( | ||
| n: v: lib.getOutput "buildprofile" v | ||
| ) componentDerivationsToProfile; | ||
|
|
||
| buildTimeReport = | ||
| pkgs.runCommand "build-time-report" | ||
| { | ||
| __impure = true; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| __structuredAttrs = true; | ||
| nativeBuildInputs = [ pkgs.clangbuildanalyzer ]; | ||
| inherit componentBuildProfiles; | ||
| } | ||
| '' | ||
| { | ||
| echo "# Build time performance profile for components:" | ||
| echo | ||
| echo "This reports the build profile collected via \`-ftime-trace\` for each component." | ||
| echo | ||
| } >> $out | ||
|
|
||
| for name in "''\${!componentBuildProfiles[@]}"; do | ||
| { | ||
| echo "<details><summary><strong>$name</strong></summary>" | ||
| echo | ||
| echo '````' | ||
| ClangBuildAnalyzer --analyze "''\${componentBuildProfiles[$name]}" | ||
| echo '````' | ||
| echo | ||
| echo "</details>" | ||
| } >> $out | ||
| done | ||
| ''; | ||
| in | ||
|
|
||
| { | ||
| inherit buildTimeReport; | ||
| inherit componentDerivationsToProfile; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edolstra in the magic action, it'd be good to avoid saving impure paths, because they can't be reused anyway.