From d037756a8497c5d063563fb3f46341b73ea6d6e3 Mon Sep 17 00:00:00 2001 From: guipublic Date: Tue, 26 Nov 2024 17:08:48 +0000 Subject: [PATCH 01/21] add memory report into the CI --- .github/workflows/memory_report.yml | 89 +++++++++++++++++++++++++++++ test_programs/memory_report.sh | 42 ++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 .github/workflows/memory_report.yml create mode 100755 test_programs/memory_report.sh diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml new file mode 100644 index 00000000000..8ed43c49d6c --- /dev/null +++ b/.github/workflows/memory_report.yml @@ -0,0 +1,89 @@ +name: Report Peak Memory + +on: + push: + branches: + - master + pull_request: + +jobs: + build-nargo: + runs-on: ubuntu-latest + strategy: + matrix: + target: [x86_64-unknown-linux-gnu] + + steps: + - name: Checkout Noir repo + uses: actions/checkout@v4 + + - name: Setup toolchain + uses: dtolnay/rust-toolchain@1.74.1 + + - uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + cache-on-failure: true + save-if: ${{ github.event_name != 'merge_group' }} + + - name: Build Nargo + run: cargo build --package nargo_cli --release + + - name: Package artifacts + run: | + mkdir dist + cp ./target/release/nargo ./dist/nargo + 7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: nargo + path: ./dist/* + retention-days: 3 + + compare_brillig_bytecode_size_reports: + needs: [build-nargo] + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - uses: actions/checkout@v4 + + - name: Download nargo binary + uses: actions/download-artifact@v4 + with: + name: nargo + path: ./nargo + + - name: Set nargo on PATH + run: | + nargo_binary="${{ github.workspace }}/nargo/nargo" + chmod +x $nargo_binary + echo "$(dirname $nargo_binary)" >> $GITHUB_PATH + export PATH="$PATH:$(dirname $nargo_binary)" + nargo -V + + - name: Generate Memory report + working-directory: ./test_programs + run: | + chmod +x memory_report.sh + ./memory_brillig.sh + mv memory_report.json ../memory_report.json + + - name: Parse memory report + id: brillig_bytecode_diff + uses: noir-lang/noir-gates-diff@b0319af9e4250743f5db73cef98d2d08fc92c5f7 + with: + report: memory_report.json + header: | + # Memory Report + memory_report: true + + - name: Add memory report to sticky comment + if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: memory + message: ${{ steps.memory_report.outputs.markdown }} \ No newline at end of file diff --git a/test_programs/memory_report.sh b/test_programs/memory_report.sh new file mode 100755 index 00000000000..055806a6596 --- /dev/null +++ b/test_programs/memory_report.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -e + +sudo apt-get install heaptrack + +NARGO="nargo" + + +# Tests to be profiled for memory report +tests_to_profile=("keccak256" "workspace" "regression_4709") + +current_dir=$(pwd) +execution_success_path="$current_dir/execution_success" +test_dirs=$(ls $execution_success_path) + +FIRST="1" + +echo "{\"memory_reports\": [ " > memory_report.json + + +for test_name in ${tests_to_profile[@]}; do + full_path=$execution_success_path"/"$test_name + cd $full_path + + if [ $FIRST = "1" ] + then + FIRST="0" + else + echo " ," >> $current_dir"/memory_report.json" + fi + heaptrack --output $current_dir/$test_name"_heap" $NARGO compile --force + heaptrack --analyze $current_dir/$test_name"_heap.gz" > $current_dir/$test_name"_heap_analysis.txt" + rm $current_dir/$test_name"_heap.gz" + consumption="$(grep 'peak heap memory consumption' $current_dir/$test_name'_heap_analysis.txt')" + len=${#consumption}-30 + peak=${consumption:30:len} + rm $current_dir/$test_name"_heap_analysis.txt" + echo -e " {\n \"artifact_name\":\"$test_name\",\n \"peak_memory\":\"$peak\"\n }" >> $current_dir"/memory_report.json" +done + +echo "]}" >> $current_dir"/memory_report.json" + From 7411aac37f393f15aa8767960ff3b6a16967a144 Mon Sep 17 00:00:00 2001 From: guipublic Date: Tue, 26 Nov 2024 17:21:45 +0000 Subject: [PATCH 02/21] fix typo in the new workflow --- .github/workflows/memory_report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 8ed43c49d6c..50c94b30dc0 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -69,11 +69,11 @@ jobs: working-directory: ./test_programs run: | chmod +x memory_report.sh - ./memory_brillig.sh + ./memory_report.sh mv memory_report.json ../memory_report.json - name: Parse memory report - id: brillig_bytecode_diff + id: memory_report uses: noir-lang/noir-gates-diff@b0319af9e4250743f5db73cef98d2d08fc92c5f7 with: report: memory_report.json From ab7ff5e7479d1ae07642e059fe046e1e5f4bb8d2 Mon Sep 17 00:00:00 2001 From: guipublic Date: Tue, 26 Nov 2024 17:30:12 +0000 Subject: [PATCH 03/21] heaptrack output is not consistent --- test_programs/memory_report.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test_programs/memory_report.sh b/test_programs/memory_report.sh index 055806a6596..edb254c4ae4 100755 --- a/test_programs/memory_report.sh +++ b/test_programs/memory_report.sh @@ -29,8 +29,14 @@ for test_name in ${tests_to_profile[@]}; do echo " ," >> $current_dir"/memory_report.json" fi heaptrack --output $current_dir/$test_name"_heap" $NARGO compile --force - heaptrack --analyze $current_dir/$test_name"_heap.gz" > $current_dir/$test_name"_heap_analysis.txt" - rm $current_dir/$test_name"_heap.gz" + if test -f $current_dir/$test_name"_heap.gz"; + then + heaptrack --analyze $current_dir/$test_name"_heap.gz" > $current_dir/$test_name"_heap_analysis.txt" + rm $current_dir/$test_name"_heap.gz" + else + heaptrack --analyze $current_dir/$test_name"_heap.zst" > $current_dir/$test_name"_heap_analysis.txt" + rm $current_dir/$test_name"_heap.zst" + fi consumption="$(grep 'peak heap memory consumption' $current_dir/$test_name'_heap_analysis.txt')" len=${#consumption}-30 peak=${consumption:30:len} From 1550a914da1fd49e39e4077f340a57bfcee06cae Mon Sep 17 00:00:00 2001 From: guipublic Date: Tue, 26 Nov 2024 18:12:21 +0000 Subject: [PATCH 04/21] update noir-diff version --- .github/workflows/gates_report_brillig.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gates_report_brillig.yml b/.github/workflows/gates_report_brillig.yml index e7ec30923f0..ea549db9dbe 100644 --- a/.github/workflows/gates_report_brillig.yml +++ b/.github/workflows/gates_report_brillig.yml @@ -74,7 +74,7 @@ jobs: - name: Compare Brillig bytecode size reports id: brillig_bytecode_diff - uses: noir-lang/noir-gates-diff@d88f7523b013b9edd3f31c5cfddaef87a3fe1b48 + uses: noir-lang/noir-gates-diff@d8fccd8c4ba45b94a88acbc543448917e73fcfb4 with: report: gates_report_brillig.json header: | From 9781412e233b4fb8209421877631763420406f36 Mon Sep 17 00:00:00 2001 From: guipublic Date: Tue, 26 Nov 2024 18:13:30 +0000 Subject: [PATCH 05/21] rename step for memory report --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 50c94b30dc0..a9074e75929 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -42,7 +42,7 @@ jobs: path: ./dist/* retention-days: 3 - compare_brillig_bytecode_size_reports: + generate_memory_report: needs: [build-nargo] runs-on: ubuntu-latest permissions: From 4782415cacc086ef6dfb07b1266eddd7a22f6c7f Mon Sep 17 00:00:00 2001 From: guipublic Date: Wed, 27 Nov 2024 09:31:10 +0000 Subject: [PATCH 06/21] update noir-diff rev --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index a9074e75929..6585f06d713 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@b0319af9e4250743f5db73cef98d2d08fc92c5f7 + uses: noir-lang/noir-gates-diff@64d5c39fa1b1e9eea81653f629bd2f2e42df3303 with: report: memory_report.json header: | From 9dcd040b9f44561fbfb4e76c3fd37a0bf1aab5d9 Mon Sep 17 00:00:00 2001 From: guipublic Date: Wed, 27 Nov 2024 11:11:56 +0000 Subject: [PATCH 07/21] update noir-diff rev for debugging --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 6585f06d713..1bd3784783c 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@64d5c39fa1b1e9eea81653f629bd2f2e42df3303 + uses: noir-lang/noir-gates-diff@cc6fa113493bb6848dce43473900bd62495fe229 with: report: memory_report.json header: | From d36955c19ce30889cfe0a7758d569931d85e4f91 Mon Sep 17 00:00:00 2001 From: guipublic Date: Wed, 27 Nov 2024 11:27:59 +0000 Subject: [PATCH 08/21] revert gate-diff change for previous report --- .github/workflows/gates_report_brillig.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gates_report_brillig.yml b/.github/workflows/gates_report_brillig.yml index ea549db9dbe..e7ec30923f0 100644 --- a/.github/workflows/gates_report_brillig.yml +++ b/.github/workflows/gates_report_brillig.yml @@ -74,7 +74,7 @@ jobs: - name: Compare Brillig bytecode size reports id: brillig_bytecode_diff - uses: noir-lang/noir-gates-diff@d8fccd8c4ba45b94a88acbc543448917e73fcfb4 + uses: noir-lang/noir-gates-diff@d88f7523b013b9edd3f31c5cfddaef87a3fe1b48 with: report: gates_report_brillig.json header: | From bb24b06997f3ee30404d5b119df249d4597b043a Mon Sep 17 00:00:00 2001 From: guipublic Date: Wed, 27 Nov 2024 11:50:20 +0000 Subject: [PATCH 09/21] for debugging --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 1bd3784783c..470741fcf1c 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@cc6fa113493bb6848dce43473900bd62495fe229 + uses: noir-lang/noir-gates-diff@0f94f7307a763d8b6494b9ca920881d064bebf6f with: report: memory_report.json header: | From 412b55a5eb19aea829a04deffbf0a59834584f2c Mon Sep 17 00:00:00 2001 From: guipublic Date: Wed, 27 Nov 2024 12:02:28 +0000 Subject: [PATCH 10/21] debug.. --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 470741fcf1c..cd3397fc234 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@0f94f7307a763d8b6494b9ca920881d064bebf6f + uses: noir-lang/noir-gates-diff@8d26ae24d1c8a1b1c6bf62cac954c72777a9a829 with: report: memory_report.json header: | From b7cfc2efbdbe345a5b14d904c394e8fe93cc7030 Mon Sep 17 00:00:00 2001 From: guipublic Date: Wed, 27 Nov 2024 12:10:36 +0000 Subject: [PATCH 11/21] debugging --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index cd3397fc234..400a036038b 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@8d26ae24d1c8a1b1c6bf62cac954c72777a9a829 + uses: noir-lang/noir-gates-diff@325e1eebb31e4007a178ea4ef357e69422f40370 with: report: memory_report.json header: | From a50d21a98b8bd709f2678061d7829fe323b14638 Mon Sep 17 00:00:00 2001 From: guipublic Date: Wed, 27 Nov 2024 12:19:12 +0000 Subject: [PATCH 12/21] debug.. --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 400a036038b..7a2c53bb3d1 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@325e1eebb31e4007a178ea4ef357e69422f40370 + uses: noir-lang/noir-gates-diff@ea0644b24f46fb6851467f80b27b03985abdfaab with: report: memory_report.json header: | From 4313b53747f4f429d7a4592a0200706200b2b059 Mon Sep 17 00:00:00 2001 From: guipublic Date: Thu, 28 Nov 2024 12:52:32 +0000 Subject: [PATCH 13/21] diff for memory report --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 7a2c53bb3d1..b5fd740fc6e 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@ea0644b24f46fb6851467f80b27b03985abdfaab + uses: noir-lang/noir-gates-diff@3c005d02b9e33173451e767f2b0d5787a7ac9a10 with: report: memory_report.json header: | From d6b4cf5cce8fcce2f20da3bbbf5b754b9e4c5924 Mon Sep 17 00:00:00 2001 From: guipublic Date: Thu, 28 Nov 2024 13:50:34 +0000 Subject: [PATCH 14/21] update noir-diff --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index b5fd740fc6e..1c642276ca7 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@3c005d02b9e33173451e767f2b0d5787a7ac9a10 + uses: noir-lang/noir-gates-diff@0458752d4cbc280727c9f3b1f757404b6322cd43 with: report: memory_report.json header: | From 984504453df6c9969feb11b865b936ad739cba33 Mon Sep 17 00:00:00 2001 From: guipublic Date: Thu, 28 Nov 2024 14:01:41 +0000 Subject: [PATCH 15/21] update noir-diff for debugging --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 1c642276ca7..bab6923708b 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@0458752d4cbc280727c9f3b1f757404b6322cd43 + uses: noir-lang/noir-gates-diff@a509f1b1d22d4db9357d501fc0574cc56bf6e7dc with: report: memory_report.json header: | From f4d635efeb25f55b0e1bd8e5f4011843b06d644b Mon Sep 17 00:00:00 2001 From: guipublic Date: Thu, 28 Nov 2024 14:22:21 +0000 Subject: [PATCH 16/21] new noir-diff for debug --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index bab6923708b..2497785b062 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@a509f1b1d22d4db9357d501fc0574cc56bf6e7dc + uses: noir-lang/noir-gates-diff@9ae3f7c8477e9074fbd66c79e257f19e2dd91af7 with: report: memory_report.json header: | From 09228a930a4faeb8ed36b0611687ebd20ea32322 Mon Sep 17 00:00:00 2001 From: guipublic Date: Thu, 28 Nov 2024 14:41:40 +0000 Subject: [PATCH 17/21] update noir-diff --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 2497785b062..565a2689658 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@9ae3f7c8477e9074fbd66c79e257f19e2dd91af7 + uses: noir-lang/noir-gates-diff@a875401e6142a7098d4e0826e645b207697af90c with: report: memory_report.json header: | From 04b1b82453aac6099c0b604eab5fb94c50b0a928 Mon Sep 17 00:00:00 2001 From: guipublic Date: Thu, 28 Nov 2024 17:54:37 +0000 Subject: [PATCH 18/21] switch to noir-bench-report repo --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 565a2689658..696ce53922f 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -74,7 +74,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-gates-diff@a875401e6142a7098d4e0826e645b207697af90c + uses: noir-lang/noir-bench-report@91003b0bfe46c4e42c1714f9450917d0103c57ca with: report: memory_report.json header: | From 960c6600db6306584fa623fb3b4489423afb8a19 Mon Sep 17 00:00:00 2001 From: guipublic Date: Mon, 2 Dec 2024 13:58:56 +0000 Subject: [PATCH 19/21] add heaptrack to the dictionary --- cspell.json | 1 + 1 file changed, 1 insertion(+) diff --git a/cspell.json b/cspell.json index 36bba737cd7..15bba2cb5f8 100644 --- a/cspell.json +++ b/cspell.json @@ -106,6 +106,7 @@ "Guillaume", "gzipped", "hasher", + "heaptrack", "hexdigit", "higher-kinded", "Hindley-Milner", From 7e4d0f7919b6c8ff3635bcdd13e49aa146fbf334 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:17:26 +0000 Subject: [PATCH 20/21] Update .github/workflows/memory_report.yml --- .github/workflows/memory_report.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 696ce53922f..3fa0d207d44 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -33,7 +33,6 @@ jobs: run: | mkdir dist cp ./target/release/nargo ./dist/nargo - 7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz - name: Upload artifact uses: actions/upload-artifact@v4 From 8b446960906ac9f5fd2650ade47185100ee66031 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:17:31 +0000 Subject: [PATCH 21/21] Update .github/workflows/memory_report.yml --- .github/workflows/memory_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/memory_report.yml b/.github/workflows/memory_report.yml index 3fa0d207d44..a1b28aee31d 100644 --- a/.github/workflows/memory_report.yml +++ b/.github/workflows/memory_report.yml @@ -73,7 +73,7 @@ jobs: - name: Parse memory report id: memory_report - uses: noir-lang/noir-bench-report@91003b0bfe46c4e42c1714f9450917d0103c57ca + uses: noir-lang/noir-bench-report@d61bc78ece3c8df1e72914b3d5136bad403d5bdf with: report: memory_report.json header: |