Skip to content

Commit

Permalink
Merge branch 'rust' into merge-turbo-tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Oct 11, 2022
2 parents 480bbfa + 00aa7a3 commit 261aea9
Show file tree
Hide file tree
Showing 838 changed files with 155,398 additions and 1,473 deletions.
11 changes: 11 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[env]
CARGO_WORKSPACE_DIR = { value = "", relative = true }

[build]
rustflags = ["--cfg", "tokio_unstable"]

[target.x86_64-pc-windows-msvc]
linker = "rust-lld"

[alias]
xtask = "run --package xtask --"
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
module.exports = {
root: true,
extends: ["next", "prettier"],
ignorePatterns: [
".yarn",
"target",
"dist",
"node_modules",
"crates",
"packages/create-turbo/templates",
"packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose",
],
settings: {
next: {
rootDir: ["docs/", "create-turbo/"],
Expand All @@ -9,4 +18,12 @@ module.exports = {
rules: {
"@next/next/no-html-link-for-pages": "off",
},
overrides: [
{
files: ["./docs/theme.config.js"],
rules: {
"react-hooks/rules-of-hooks": "off",
},
},
],
};
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
crates/turbopack/tests/snapshot/*/output/** linguist-generated=true
16 changes: 12 additions & 4 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ inputs:
description: "Control turning on corepack."
required: false
default: true
disable-scripts:
description: "Control turning on installation scripts."
required: false
default: false
runs:
using: "composite"
steps:
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 7.2.1
version: 7.12.1

- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm
Expand All @@ -28,13 +32,17 @@ runs:
npm install --force --global corepack@latest
npm config get prefix >> $GITHUB_PATH
corepack enable
- name: Enable corepack
if: ${{ inputs.enable-corepack == 'true' }}
shell: bash
run: |
corepack enable
- name: pnpm install
if: ${{ inputs.disable-scripts == 'false' }}
shell: bash
run: pnpm install

- name: pnpm install
if: ${{ inputs.disable-scripts == 'true' }}
shell: bash
run: pnpm install --ignore-scripts
151 changes: 151 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Benchmark

on:
push:
branches: [main]

env:
CARGO_TERM_COLOR: always
CARGO_PROFILE_RELEASE_LTO: true
RUST_BACKTRACE: 1
NODE_OPTIONS: "--max-old-space-size=32768"

jobs:
bench:
strategy:
fail-fast: false
matrix:
bench:
# One of Turbopack CSR or SSR with 1000 modules is benchmarked in every run
# to create a baseline result for normalization (should the runners performance vary between jobs)

# This runs all the non next-dev benchmarks
- name: generic
cache_key: all
TURBOPACK_BENCH_COUNTS: 1000

# This measures Turbopack CSR and SSR
- name: turbopack
cache_key: next-dev
args: -p next-dev
TURBOPACK_BENCH_COUNTS: 100,500,1000

# This measures Turbopack CSR and SSR with larger apps
- name: turbopack-large
cache_key: next-dev
args: -p next-dev
TURBOPACK_BENCH_COUNTS: 1000,2000,3000

# This measures Next.js 12
- name: next 12
cache_key: next-dev
args: -p next-dev -- "(Turbopack SSR/1000|Next.js 12)"
TURBOPACK_BENCH_COUNTS: 100,500,1000
TURBOPACK_BENCH_BUNDLERS: all

# This measures Next.js 11
- name: next 11
cache_key: next-dev
args: -p next-dev -- "(Turbopack SSR/1000|Next.js 11)"
TURBOPACK_BENCH_COUNTS: 100,500,1000
TURBOPACK_BENCH_BUNDLERS: all

# This measures Vite
- name: vite
cache_key: next-dev
args: -p next-dev -- "(Turbopack CSR/1000|Vite)"
TURBOPACK_BENCH_COUNTS: 100,500,1000
TURBOPACK_BENCH_BUNDLERS: all

# This measures Parcel
- name: parcel
cache_key: next-dev
args: -p next-dev -- "(Turbopack CSR/1000|Parcel)"
TURBOPACK_BENCH_COUNTS: 100,500,1000
TURBOPACK_BENCH_BUNDLERS: all

# This measures Webpack
- name: webpack
cache_key: next-dev
args: -p next-dev -- "(Turbopack CSR/1000|Webpack)"
TURBOPACK_BENCH_COUNTS: 100,500,1000
TURBOPACK_BENCH_BUNDLERS: all

runs-on: ubuntu-latest-16-core
name: bench - ${{ matrix.bench.name }}

steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/setup-node

- uses: Swatinem/rust-cache@v1
with:
key: benchmark-${{ matrix.bench.cache_key }}

- name: Clear benchmarks
run: rm -rf target/criterion

- name: Run cargo bench
uses: actions-rs/cargo@v1
timeout-minutes: 90
env:
TURBOPACK_BENCH_BUNDLERS: ${{ matrix.bench.TURBOPACK_BENCH_BUNDLERS }}
TURBOPACK_BENCH_COUNTS: ${{ matrix.bench.TURBOPACK_BENCH_COUNTS }}
with:
command: bench
args: ${{ matrix.bench.args }}

- name: Install critcmp
if: always()
uses: actions-rs/cargo@v1
with:
command: install
args: critcmp

- name: Compare results
if: always()
run: critcmp --group "([^/]+/)[^/]+(?:/)(.+)" base

- name: Export results
if: always()
run: critcmp --export base > raw.json

- name: Upload results
if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.bench.name }}
path: raw.json

# This avoids putting this data into the rust-cache
- name: Clear benchmarks
run: rm -rf target/criterion

commit_results:
name: Commit benchmark-data
needs: bench
if: always()
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: |
echo "::set-output name=year::$(date +'%Y')"
echo "::set-output name=month::$(date +'%m')"
echo "::set-output name=date::$(date +'%s')"
echo "::set-output name=pretty::$(date +'%Y-%m-%d %H:%M')"
- name: Checkout benchmark-data
uses: actions/checkout@v3
with:
ref: benchmark-data
- name: Download benchmark data
uses: actions/download-artifact@v3
with:
path: data/${{ steps.date.outputs.year }}/${{ steps.date.outputs.month }}/ubuntu-latest-16-core/${{ steps.date.outputs.date }}-${{ github.sha }}
- name: Git pull
run: git pull --depth=1 --no-tags origin benchmark-data
- name: Push data to branch
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Benchmark result for ${{ steps.date.outputs.pretty }} (${{ github.sha }})
41 changes: 41 additions & 0 deletions .github/workflows/bench_against_node_nft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Bench against @vercel/nft

on:
push:
branches: [main]

env:
CARGO_TERM_COLOR: always
CARGO_PROFILE_RELEASE_LTO: true
RUST_BACKTRACE: 1

jobs:
bench_vs_node_nft:
# for edited events it should only run on base changes
runs-on: ubuntu-latest
name: bench

steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
with:
key: bench_nft

- uses: ./.github/actions/setup-node

- name: Install nextest
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
shell: bash

- name: Run benchmark
uses: actions-rs/cargo@v1
timeout-minutes: 60
with:
command: nextest
args: run -j 1 --no-fail-fast -r -p turbopack --features bench_against_node_nft bench_against_node_nft

- name: Show benchmark result
uses: actions-rs/cargo@v1
with:
command: xtask
args: nft-bench-result
58 changes: 58 additions & 0 deletions .github/workflows/bench_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Benchmark PR

on:
pull_request:
types: [synchronize, opened, reopened, edited]
branches: [main]

env:
CARGO_TERM_COLOR: always
CARGO_PROFILE_RELEASE_LTO: true
RUST_BACKTRACE: 1

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-${{ github.event.action != 'edited' || github.event.changes.base != '' }}
cancel-in-progress: ${{ github.event.action != 'edited' || github.event.changes.base != '' }}

jobs:
bench:
# for edited events it should only run on base changes
if: ${{ github.event.action != 'edited' || github.event.changes.base != '' }}
runs-on: ubuntu-latest-16-core

steps:
- name: Initialize github status
uses: ouzi-dev/[email protected]
with:
name: Benchmark PR / bench (pull_request)
url: https://github.com/vercel/turbo-tooling/actions/runs/${{ github.run_id }}

- uses: actions/checkout@v3

- name: Fetch the base branch
run: git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --depth=1 origin +${{ github.base_ref }}:base

- uses: ./.github/actions/setup-node

- uses: Swatinem/rust-cache@v1
with:
key: benchmark

- uses: sokra/criterion-compare-action@main
timeout-minutes: 180
with:
branchName: base

- name: Upload report
if: always()
uses: actions/upload-artifact@v3
with:
name: benchmark report
path: target/criterion/
- name: Report github status
if: always()
uses: ouzi-dev/[email protected]
with:
name: Benchmark PR / bench (pull_request)
status: "${{ job.status }}"
url: https://github.com/vercel/turbo-tooling/actions/runs/${{ github.run_id }}
Loading

0 comments on commit 261aea9

Please sign in to comment.