- 
                Notifications
    You must be signed in to change notification settings 
- Fork 7
Benchmark Comparison Workflow #331
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
          
     Draft
      
      
            ajay-mk
  wants to merge
  15
  commits into
  master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
ajay/feature/benchmark-workflow
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Draft
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            15 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      39a0dc8
              
                benchmark: add an alternate benchmark target to just run cc benchmarks
              
              
                ajay-mk 49a2133
              
                benchmark: reduce max CC rank to 15
              
              
                ajay-mk 556ce00
              
                locale: can optionally disable thousands operator
              
              
                ajay-mk 6c8649c
              
                benchmark: disable thousands separator in benchmark output
              
              
                ajay-mk 4b65ea0
              
                benchmark: introduce python script for benchmark comparison
              
              
                ajay-mk 7d75d93
              
                ci: introduce benchmark comparison workflow
              
              
                ajay-mk bfe6010
              
                ci: avoid duplicate benchmark workflows
              
              
                ajay-mk 1bad32d
              
                ci: remove some debug info [skip ci]
              
              
                ajay-mk 2761c29
              
                Merge remote-tracking branch 'origin/master' into ajay/feature/benchm…
              
              
                ajay-mk 1df8cfb
              
                Merge branch 'master' into ajay/feature/benchmark-workflow
              
              
                evaleev 32af3b8
              
                benchmark: improve filename handling, make `compare_benchmarks` reusable
              
              
                ajay-mk 510ef15
              
                ci: update output file name in benchmark_compare.yml
              
              
                ajay-mk c88cbb2
              
                benchmark: enforce release build, even though it is the default
              
              
                ajay-mk 9667369
              
                fix typo
              
              
                ajay-mk ec357be
              
                Merge branch 'master' into ajay/feature/benchmark-workflow
              
              
                evaleev File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| name: Compare Benchmarks | ||
|  | ||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
| workflow_dispatch: | ||
| inputs: | ||
| pr_number: | ||
| description: 'PR number to run benchmarks for' | ||
| required: true | ||
| type: number | ||
|  | ||
| concurrency: | ||
| group: benchmark-${{ github.event.issue.number || github.event.inputs.pr_number }} | ||
| cancel-in-progress: true | ||
|  | ||
| jobs: | ||
| benchmark: | ||
| if: > | ||
| (github.event_name == 'issue_comment' | ||
| && github.event.issue.pull_request | ||
| && contains(github.event.comment.body, '/benchmark') | ||
| && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') | ||
| ) || github.event_name == 'workflow_dispatch' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| actions: read | ||
| statuses: write | ||
|  | ||
| steps: | ||
| - name: Get PR details | ||
| id: pr | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| let pullRequestNumber; | ||
|  | ||
| if (context.eventName === 'workflow_dispatch') { | ||
| // Manual dispatch - use provided PR number | ||
| pullRequestNumber = parseInt('${{ github.event.inputs.pr_number }}'); | ||
| } else { | ||
| // PR comment trigger - use PR number | ||
| pullRequestNumber = context.issue.number; | ||
| } | ||
|  | ||
| // Fetch PR details | ||
| const { data: pullRequest } = await github.rest.pulls.get({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: pullRequestNumber, | ||
| }); | ||
|  | ||
| const is_fork = pullRequest.head.repo.full_name !== pullRequest.base.repo.full_name; | ||
| return { | ||
| base_sha: pullRequest.base.sha, | ||
| head_sha: pullRequest.head.sha, | ||
| base_ref: pullRequest.base.ref, | ||
| head_ref: pullRequest.head.ref, | ||
| head_repo_full_name: pullRequest.head.repo.full_name, | ||
| base_repo_full_name: pullRequest.base.repo.full_name, | ||
| is_fork: is_fork, | ||
| pr_number: pullRequestNumber | ||
| }; | ||
|  | ||
| - name: Create status check | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const prData = ${{ steps.pr.outputs.result }}; | ||
| await github.rest.repos.createCommitStatus({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| sha: prData.head_sha, | ||
| state: 'pending', | ||
| target_url: `${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`, | ||
| description: 'Running benchmark comparison...', | ||
| context: 'comparing benchmarks' | ||
| }); | ||
|  | ||
| - name: Checkout base repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|  | ||
| - name: Add fork as remote and fetch (if needed) | ||
| if: fromJson(steps.pr.outputs.result).is_fork | ||
| run: | | ||
| echo "PR is from fork: ${{ fromJson(steps.pr.outputs.result).head_repo_full_name }}" | ||
| git remote add fork https://github.com/${{ fromJson(steps.pr.outputs.result).head_repo_full_name }}.git | ||
| git fetch fork | ||
|  | ||
| - name: Verify commits | ||
| run: | | ||
| echo "=== Git Remotes ===" | ||
| git remote -v | ||
| echo "=== Base commit ===" | ||
| echo "${{ fromJson(steps.pr.outputs.result).base_sha }}" | ||
| echo "=== Head commit ===" | ||
| echo "${{ fromJson(steps.pr.outputs.result).head_sha }}" | ||
|  | ||
| - name: Install Dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y cmake ninja-build libboost-dev libboost-locale-dev libboost-random-dev libboost-regex-dev libeigen3-dev libmimalloc-dev | ||
|  | ||
| - name: Run Benchmark Script | ||
| working-directory: ${{ github.workspace }} | ||
| run: python3 bin/admin/benchmark_compare.py ${{ fromJson(steps.pr.outputs.result).base_sha }} ${{ fromJson(steps.pr.outputs.result).head_sha }} | ||
|  | ||
| - name: Upload Results | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: benchmark-data | ||
| path: | | ||
| ${{ github.workspace }}/${{ fromJson(steps.pr.outputs.result).base_sha }}-results.json | ||
| ${{ github.workspace }}/${{ fromJson(steps.pr.outputs.result).head_sha }}-results.json | ||
| ${{ github.workspace }}/benchmark-comparison.txt | ||
| retention-days: 30 | ||
|  | ||
| - name: Post Results | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|  | ||
| const prData = ${{ steps.pr.outputs.result }}; | ||
| const comparisonFile = `benchmark-comparison.txt`; | ||
| const comparisonPath = path.join('${{ github.workspace }}', comparisonFile); | ||
|  | ||
| let comparisonResults = ''; | ||
| try { | ||
| comparisonResults = fs.readFileSync(comparisonPath, 'utf8'); | ||
| } catch (error) { | ||
| comparisonResults = 'Error reading comparison results: ' + error.message; | ||
| } | ||
|  | ||
| const commentBody = `## Benchmark Comparison Results | ||
|  | ||
| \`\`\` | ||
| ${comparisonResults} | ||
| \`\`\` | ||
|  | ||
| #### [Full benchmark data](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | ||
| `; | ||
|  | ||
| github.rest.issues.createComment({ | ||
| issue_number: prData.pr_number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: commentBody | ||
| }); | ||
|  | ||
| - name: Update status check - Success | ||
| if: success() | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const prData = ${{ steps.pr.outputs.result }}; | ||
| await github.rest.repos.createCommitStatus({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| sha: prData.head_sha, | ||
| state: 'success', | ||
| target_url: `${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`, | ||
| description: 'Benchmark comparison completed successfully', | ||
| context: 'comparing benchmarks' | ||
| }); | ||
|  | ||
| - name: Notify on Failure | ||
| if: failure() | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const prData = ${{ steps.pr.outputs.result }}; | ||
|  | ||
| // Update status check to failed | ||
| await github.rest.repos.createCommitStatus({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| sha: prData.head_sha, | ||
| state: 'failure', | ||
| target_url: `${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`, | ||
| description: 'Benchmark comparison failed', | ||
| context: 'comparing benchmarks' | ||
| }); | ||
|  | ||
| // Post failure comment | ||
| github.rest.issues.createComment({ | ||
| issue_number: prData.pr_number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: 'Benchmark comparison failed. Check the workflow logs for details.' | ||
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.