mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Merge pull request #13510 from xokdvium/build-profiling
This commit is contained in:
commit
7e184bbc29
2 changed files with 124 additions and 0 deletions
23
.github/workflows/ci.yml
vendored
23
.github/workflows/ci.yml
vendored
|
|
@ -221,3 +221,26 @@ jobs:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
- run: nix build -L --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
|
- run: nix build -L --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
|
||||||
|
|
||||||
|
profile_build:
|
||||||
|
needs: tests
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
timeout-minutes: 60
|
||||||
|
if: >-
|
||||||
|
github.event_name == 'push' &&
|
||||||
|
github.ref_name == 'master'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- uses: ./.github/actions/install-nix-action
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
dogfood: true
|
||||||
|
extra_nix_config: |
|
||||||
|
experimental-features = flakes nix-command ca-derivations impure-derivations
|
||||||
|
max-jobs = 1
|
||||||
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
|
- run: |
|
||||||
|
nix build -L --file ./ci/gha/profile-build buildTimeReport --out-link build-time-report.md
|
||||||
|
cat build-time-report.md >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
|
||||||
101
ci/gha/profile-build/default.nix
Normal file
101
ci/gha/profile-build/default.nix
Normal file
|
|
@ -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 = {
|
||||||
|
"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;
|
||||||
|
__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;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue