|
3 | 3 | pull_request: |
4 | 4 | paths: |
5 | 5 | - 'stack-graphs/**' |
6 | | -env: |
7 | | - BASE_REPO: ${{ github.event.pull_request.base.repo.owner.login }}/${{ github.event.pull_request.base.repo.name }} |
8 | | - BASE_SHA: ${{ github.event.pull_request.base.sha }} |
9 | | - HEAD_REPO: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.event.pull_request.head.repo.name }} |
10 | | - HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
11 | | - BIN: tree-sitter-stack-graphs-typescript |
12 | | - TEST_DIR: perf |
13 | | - TEST_SRC: src/compiler/binder.ts |
14 | | - MASSIF_OUT: perf.out |
15 | 6 |
|
16 | 7 | jobs: |
17 | | - base-perf: |
| 8 | + typescript-compiler-src: |
18 | 9 | runs-on: ubuntu-latest |
19 | | - outputs: |
20 | | - massif-out: ${{ steps.set-output.outputs.massif-out }} |
21 | | - steps: |
22 | | - - name: Install Rust environment |
23 | | - uses: hecrj/setup-rust-action@v1 |
24 | | - with: |
25 | | - rust-version: stable |
26 | | - - name: Cache dependencies |
27 | | - uses: actions/cache@v3 |
28 | | - with: |
29 | | - path: | |
30 | | - ~/.cargo |
31 | | - target |
32 | | - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
33 | | - restore-keys: | |
34 | | - ${{ runner.OS }}-cargo- |
35 | | - - name: Install valgrind |
36 | | - run: | |
37 | | - sudo apt-get update |
38 | | - sudo apt-get install -y valgrind |
39 | | - - name: Checkout code |
40 | | - uses: actions/checkout@v3 |
41 | | - with: |
42 | | - repository: ${{ env.BASE_REPO }} |
43 | | - ref: ${{ env.BASE_SHA }} |
44 | | - - name: Build CLI |
45 | | - run: cargo build --package ${{ env.BIN }} --features cli --release |
46 | | - env: |
47 | | - CARGO_PROFILE_RELEASE_DEBUG: true |
48 | | - - name: Checkout test code |
49 | | - uses: actions/checkout@v3 |
50 | | - with: |
51 | | - repository: microsoft/TypeScript |
52 | | - ref: v4.9.5 |
53 | | - path: ${{ env.TEST_DIR }} |
54 | | - - name: Profile memory |
55 | | - run: | |
56 | | - valgrind \ |
57 | | - --tool=massif \ |
58 | | - --massif-out-file=${{ env.MASSIF_OUT }} \ |
59 | | - target/release/${{ env.BIN }} \ |
60 | | - analyze --max-file-time=30 --hide-error-details -- ${{ env.TEST_DIR }}/${{ env.TEST_SRC }} |
61 | | - - name: Set output |
62 | | - id: set-output |
63 | | - run: | |
64 | | - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) |
65 | | - echo "massif-out<<$EOF" >> $GITHUB_OUTPUT |
66 | | - cat ${{ env.MASSIF_OUT }} >> $GITHUB_OUTPUT |
67 | | - echo "$EOF" >> $GITHUB_OUTPUT |
68 | | -
|
69 | | - head-perf: |
70 | | - runs-on: ubuntu-latest |
71 | | - outputs: |
72 | | - massif-out: ${{ steps.set-output.outputs.massif-out }} |
73 | | - steps: |
74 | | - - name: Install Rust environment |
75 | | - uses: hecrj/setup-rust-action@v1 |
76 | | - with: |
77 | | - rust-version: stable |
78 | | - - name: Cache dependencies |
79 | | - uses: actions/cache@v3 |
80 | | - with: |
81 | | - path: | |
82 | | - ~/.cargo |
83 | | - target |
84 | | - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
85 | | - restore-keys: | |
86 | | - ${{ runner.OS }}-cargo- |
87 | | - - name: Install valgrind |
88 | | - run: | |
89 | | - sudo apt-get update |
90 | | - sudo apt-get install -y valgrind |
91 | | - - name: Checkout code |
92 | | - uses: actions/checkout@v3 |
93 | | - with: |
94 | | - repository: ${{ env.HEAD_REPO }} |
95 | | - ref: ${{ env.HEAD_SHA }} |
96 | | - - name: Build CLI |
97 | | - run: cargo build --package ${{ env.BIN }} --features cli --release |
98 | | - env: |
99 | | - CARGO_PROFILE_RELEASE_DEBUG: true |
100 | | - - name: Checkout test code |
101 | | - uses: actions/checkout@v3 |
102 | | - with: |
103 | | - repository: microsoft/TypeScript |
104 | | - ref: v4.9.5 |
105 | | - path: ${{ env.TEST_DIR }} |
106 | | - - name: Profile memory |
107 | | - run: | |
108 | | - valgrind \ |
109 | | - --tool=massif \ |
110 | | - --massif-out-file=${{ env.MASSIF_OUT }} \ |
111 | | - target/release/${{ env.BIN }} \ |
112 | | - analyze --max-file-time=30 --hide-error-details -- ${{ env.TEST_DIR }}/${{ env.TEST_SRC }} |
113 | | - - name: Set output |
114 | | - id: set-output |
115 | | - run: | |
116 | | - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) |
117 | | - echo "massif-out<<$EOF" >> $GITHUB_OUTPUT |
118 | | - cat ${{ env.MASSIF_OUT }} >> $GITHUB_OUTPUT |
119 | | - echo "$EOF" >> $GITHUB_OUTPUT |
120 | | -
|
121 | | - report: |
122 | | - runs-on: ubuntu-latest |
123 | | - needs: |
124 | | - - base-perf |
125 | | - - head-perf |
126 | | - env: |
127 | | - BASE_MASSIF_OUT: base-perf.out |
128 | | - HEAD_MASSIF_OUT: head-perf.out |
129 | | - REPORT_COMMENT: perf-report.json |
130 | | - steps: |
131 | | - - name: Install valgrind |
132 | | - run: | |
133 | | - sudo apt-get update |
134 | | - sudo apt-get install -y valgrind |
135 | | - - name: Checkout code |
136 | | - uses: actions/checkout@v3 |
137 | | - - name: Store base result |
138 | | - uses: DamianReeves/[email protected] |
139 | | - with: |
140 | | - path: ${{ env.BASE_MASSIF_OUT }} |
141 | | - contents: | |
142 | | - ${{ needs.base-perf.outputs.massif-out }} |
143 | | - - name: Store head result |
144 | | - uses: DamianReeves/[email protected] |
145 | | - with: |
146 | | - path: ${{ env.HEAD_MASSIF_OUT }} |
147 | | - contents: | |
148 | | - ${{ needs.head-perf.outputs.massif-out }} |
149 | | - - name: Generate report |
150 | | - run: | |
151 | | - script/ci-perf-report-md \ |
152 | | - ${{ env.BASE_MASSIF_OUT }} \ |
153 | | - ${{ env.HEAD_MASSIF_OUT }} \ |
154 | | - 'Comparing base ${{ env.BASE_REPO }}@${{ env.BASE_SHA }} with head ${{ env.HEAD_REPO }}@${{ env.HEAD_SHA }} on https://github.com/microsoft/TypeScript/tree/v4.9.5/src/compiler.' \ |
155 | | - | script/ci-comment-json >> ${{ env.REPORT_COMMENT }} |
156 | | - - name: Comment on PR |
157 | | - run: | |
158 | | - curl \ |
159 | | - -X POST \ |
160 | | - -H "Accept: application/vnd.github+json" \ |
161 | | - -H "Authorization: Bearer ${{ github.TOKEN }}" \ |
162 | | - -H "X-GitHub-Api-Version: 2022-11-28" \ |
163 | | - ${{ github.event.pull_request.comments_url }} \ |
164 | | - -d '@${{ env.REPORT_COMMENT }}' |
| 10 | + env: |
| 11 | + BASE_REPO: ${{ github.event.pull_request.base.repo.owner.login }}/${{ github.event.pull_request.base.repo.name }} |
| 12 | + BASE_SHA: ${{ github.event.pull_request.base.sha }} |
| 13 | + BASE_DIR: base |
| 14 | + BASE_MASSIF_OUT: base-perf.out |
| 15 | + HEAD_REPO: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.event.pull_request.head.repo.name }} |
| 16 | + HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
| 17 | + HEAD_DIR: head |
| 18 | + HEAD_MASSIF_OUT: head-perf.out |
| 19 | + TEST_REPO: microsoft/TypeScript |
| 20 | + TEST_REF: v4.9.5 |
| 21 | + TEST_DIR: test |
| 22 | + TEST_SRC: src/compiler/binder.ts |
| 23 | + TSSG_TS: tree-sitter-stack-graphs-typescript |
| 24 | + REPORT_COMMENT: perf-report.json |
| 25 | + steps: |
| 26 | + # |
| 27 | + # Install tools |
| 28 | + # |
| 29 | + - name: Install Rust environment |
| 30 | + uses: hecrj/setup-rust-action@v1 |
| 31 | + with: |
| 32 | + rust-version: stable |
| 33 | + - name: Cache dependencies |
| 34 | + uses: actions/cache@v3 |
| 35 | + with: |
| 36 | + path: | |
| 37 | + ~/.cargo |
| 38 | + ${{ env.BASE_DIR }}/target |
| 39 | + ${{ env.HEAD_DIR }}/target |
| 40 | + key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 41 | + restore-keys: | |
| 42 | + ${{ runner.OS }}-cargo- |
| 43 | + - name: Install valgrind |
| 44 | + run: | |
| 45 | + sudo apt-get update |
| 46 | + sudo apt-get install -y valgrind |
| 47 | + # |
| 48 | + # Checkout test code |
| 49 | + # |
| 50 | + - name: Checkout test code |
| 51 | + uses: actions/checkout@v3 |
| 52 | + with: |
| 53 | + repository: ${{ env.TEST_REPO }} |
| 54 | + ref: ${{ env.TEST_REF }} |
| 55 | + path: ${{ env.TEST_DIR }} |
| 56 | + # |
| 57 | + # Test base performance |
| 58 | + # |
| 59 | + - name: "Cache base result" |
| 60 | + id: cache-base-result |
| 61 | + uses: actions/checkout@v3 |
| 62 | + with: |
| 63 | + path: ${{ env.BASE_MASSIF_OUT }} |
| 64 | + key: ${{ runner.os }}-${{ env.BASE_REPO }}@${{ env.BASE_SHA}}-${{ env.TEST_REPO }}@${{ env.TEST_REF }} |
| 65 | + - name: "Checkout base code" |
| 66 | + if: steps.cache-base-result.outputs.cache-hit != 'true' |
| 67 | + uses: actions/checkout@v3 |
| 68 | + with: |
| 69 | + repository: ${{ env.BASE_REPO }} |
| 70 | + ref: ${{ env.BASE_SHA }} |
| 71 | + path: ${{ env.BASE_DIR }} |
| 72 | + - name: "Build base CLI" |
| 73 | + if: steps.cache-base-result.outputs.cache-hit != 'true' |
| 74 | + run: cargo build --package ${{ env.TSSG_TS }} --features cli --release |
| 75 | + working-directory: ${{ env.BASE_DIR }} |
| 76 | + env: |
| 77 | + CARGO_PROFILE_RELEASE_DEBUG: true |
| 78 | + - name: Profile base memory |
| 79 | + if: steps.cache-base-result.outputs.cache-hit != 'true' |
| 80 | + run: | |
| 81 | + valgrind \ |
| 82 | + --tool=massif \ |
| 83 | + --massif-out-file=${{ env.BASE_MASSIF_OUT }} \ |
| 84 | + ${{ env.BASE_DIR }}/target/release/${{ env.TSSG_TS }} \ |
| 85 | + analyze --max-file-time=30 --hide-error-details -- ${{ env.TEST_DIR }}/${{ env.TEST_SRC }} |
| 86 | + # |
| 87 | + # Test head performance |
| 88 | + # |
| 89 | + - name: "Cache head result" |
| 90 | + id: cache-head-result |
| 91 | + uses: actions/checkout@v3 |
| 92 | + with: |
| 93 | + path: ${{ env.HEAD_MASSIF_OUT }} |
| 94 | + key: ${{ runner.os }}-${{ env.HEAD_REPO }}@${{ env.HEAD_SHA}}-${{ env.TEST_REPO }}@${{ env.TEST_REF }} |
| 95 | + - name: "Checkout head code" |
| 96 | + if: steps.cache-head-result.outputs.cache-hit != 'true' |
| 97 | + uses: actions/checkout@v3 |
| 98 | + with: |
| 99 | + repository: ${{ env.HEAD_REPO }} |
| 100 | + ref: ${{ env.HEAD_SHA }} |
| 101 | + path: ${{ env.HEAD_DIR }} |
| 102 | + - name: "Build head CLI" |
| 103 | + if: steps.cache-head-result.outputs.cache-hit != 'true' |
| 104 | + run: cargo build --package ${{ env.TSSG_TS }} --features cli --release |
| 105 | + working-directory: ${{ env.HEAD_DIR }} |
| 106 | + env: |
| 107 | + CARGO_PROFILE_RELEASE_DEBUG: true |
| 108 | + - name: Profile head memory |
| 109 | + if: steps.cache-head-result.outputs.cache-hit != 'true' |
| 110 | + run: | |
| 111 | + valgrind \ |
| 112 | + --tool=massif \ |
| 113 | + --massif-out-file=${{ env.HEAD_MASSIF_OUT }} \ |
| 114 | + ${{ env.HEAD_DIR }}/target/release/${{ env.TSSG_TS }} \ |
| 115 | + analyze --max-file-time=30 --hide-error-details -- ${{ env.TEST_DIR }}/${{ env.TEST_SRC }} |
| 116 | + # |
| 117 | + # Create report |
| 118 | + # |
| 119 | + - name: Generate report |
| 120 | + run: | |
| 121 | + script/ci-perf-report-md \ |
| 122 | + ${{ env.BASE_MASSIF_OUT }} \ |
| 123 | + ${{ env.HEAD_MASSIF_OUT }} \ |
| 124 | + 'Comparing base ${{ env.BASE_REPO }}@${{ env.BASE_SHA }} with head ${{ env.HEAD_REPO }}@${{ env.HEAD_SHA }} on `${{ env.TEST_SRC }}` in ${{ env.TEST_REPO }}@${{ env.TEST_REF }}.' \ |
| 125 | + | script/ci-comment-json >> ${{ env.REPORT_COMMENT }} |
| 126 | + - name: Add report comment to PR |
| 127 | + run: | |
| 128 | + curl \ |
| 129 | + -X POST \ |
| 130 | + -H "Accept: application/vnd.github+json" \ |
| 131 | + -H "Authorization: Bearer ${{ github.TOKEN }}" \ |
| 132 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 133 | + ${{ github.event.pull_request.comments_url }} \ |
| 134 | + -d '@${{ env.REPORT_COMMENT }}' |
0 commit comments