summaryrefslogtreecommitdiffstats
path: root/third_party/rust/jsparagus/.github/workflows/real-js-benchmark.yml
blob: eec804776271b6eb62854785863bc236568b3e5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Real JS Samples Benchmark
on:
  pull_request:
    types: [opened, synchronize, reopened]
  push:
      branches:
      - master

jobs:
  benchmark:
    # This workflow relies on:
    #   - A specific hardware (benchmark-pool-1) in order to have a consistent
    #     and comparable results against multiple builds.
    #
    #   - Some persistent data to reduce the time needed to checkout
    #     mozilla-central.
    #
    # To setup such host multiple things should be considered.
    #
    # In terms of security, the code which is executed on this hardware should
    # not be trusted. As such, the Github Action jobs should run on a dedicated
    # computer which is either isolated or containerized. Do not run this setup
    # on a non-dedicated computer!
    #
    # It is best to create a dedicated user.
    #   $ mkdir /var/github-action-runner
    #   $ useradd -d /var/github-action-runner github-action-user
    #
    # Make sure this newly added user has no sudo capabilities.
    #
    # A checkout of Gecko should be present under /var/github-action-runner. The
    # dependencies for building Gecko should as well be installed with `mach
    # bootstrap`, which can be done using another user with sudo capabilities,
    # and changing the HOME environment variable to match the github-action-user
    # home.
    #
    # The file /var/github-action-runner/.profile contains:
    #
    #    export PATH="$HOME/.cargo/bin:$PATH"
    #    export PATH="/var/github-action-runner/.mozbuild/git-cinnabar:$PATH"
    #
    # Which is used to add cargo in the path, as well as git-cinnabar, to keep
    # the gecko clone up to date.
    #
    # To add this computer to the benchmark pool, follow the instruction
    # provided by github, after clicking "Add runner" on this page:
    #   https://github.com/mozilla-spidermonkey/jsparagus/settings/actions
    #
    # "benchmark-pool-1" specification:
    #   /proc/cpuinfo:
    #     Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
    #   dmidecode --type 17:
    #     2x Hynix/Hyundai HMT41GU6MFR8C-PB (DDR3, 8GB, 1600 MT/s)
    #
    runs-on: [self-hosted, benchmark-pool-1]
    steps:
    - name: Clean Work Directory
      run: |
        rm -rf *
    - name: Checkout jsparagus
      uses: actions/checkout@v2
      with:
        fetch-depth: 0
        path: 'jsparagus'
    - name: Checkout real-js-samples
      uses: actions/checkout@v2
      with:
        repository: 'Yoric/real-js-samples'
        path: 'real-js-samples'
        fetch-depth: 0
    - name: Checkout mozilla-central
      run: |
          # Pull mozilla-central changes
          source /var/github-action-runner/.profile
          git -C /var/github-action-runner/gecko pull --all
          # Create a local clone of mozilla-central
          git clone -l /var/github-action-runner/gecko mozilla-central
    - name: Status of Checkouts
      run: |
        echo "mozilla-central: $(git -C mozilla-central show --oneline -s)"
        echo "jsparagus: $(git -C jsparagus show --oneline -s)"
        echo "real-js-samples: $(git -C real-js-samples show --oneline -s)"
    - name: Setup venv
      run: |
        source /var/github-action-runner/.profile
        cd jsparagus
        make init
    - name: Generate Files
      run: |
        source /var/github-action-runner/.profile
        cd jsparagus
        make all
        # OS independant replace
        sed -i.bak '/*_generated.rs/d' .gitignore && rm .gitignore.bak
    - name: Apply gecko patches
      run: |
        source /var/github-action-runner/.profile
        cd mozilla-central
        cat ../jsparagus/gecko-patches.txt | while read PATCH_AND_BUG; do
          PATCH=$(echo $PATCH_AND_BUG | cut -d : -f 1)
          BUG=$(echo $PATCH_AND_BUG | cut -d : -f 2)

          # Check bug status and skip if it's already landed.
          STATUS=$(curl https://bugzilla.mozilla.org/rest/bug/$BUG | python3 -c 'import sys, json; print(json.load(sys.stdin)["bugs"][0]["status"])')
          echo "Bug $BUG $STATUS"
          if [ "x$STATUS" = "xRESOLVED" ]; then
            continue
          fi

          # Apply the latest patch from phabricator.
          PATCH_URL=https://phabricator.services.mozilla.com/${PATCH}?download=true
          curl --location "$PATCH_URL" | git apply --index || git reset --hard
          git status
          git commit --allow-empty -m "Bug $BUG"
        done
    - name: Build Gecko
      run: |
        # Disable Opcodes.h check, as we only focus on parsing speed.
        export JS_SMOOSH_DISABLE_OPCODE_CHECK=1
        # Apply Bug 1640982 fix.
        export CARGO_PROFILE_RELEASE_LTO=true
        source /var/github-action-runner/.profile
        cd jsparagus
        cargo run --bin smoosh_tools build --opt
    - name: Benchmark Real JS Samples
      run: |
        source /var/github-action-runner/.profile
        cd jsparagus
        cargo run --bin smoosh_tools bench --opt
    - name: Post Checkout mozilla-central
      if: ${{ always() }}
      run: |
          # Remove checked out repository.
          rm -rf mozilla-central