Skip to content

Commit

Permalink
chore: use more semantic naming profile (#9288)
Browse files Browse the repository at this point in the history
* chore: use more semantic profile

* chore: fix script

* chore: use ci by default

* chore: fix

* chore: use debug for windows

* chore: fix dep

* chore: adjust params

* chore: adjust production -> release
  • Loading branch information
hardfist authored Feb 14, 2025
1 parent 9c9e594 commit 5458f29
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 107 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-pc-windows-msvc
profile: "debug"
profile: "dev"
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}

Expand All @@ -124,7 +124,7 @@ jobs:
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-apple-darwin
profile: "debug"
profile: "ci"
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
with:
target: ${{ matrix.array.target }}
runner: ${{ matrix.array.runner }}
profile: "release-prod"
profile: "release"
test: false

publish:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ on:
default: release
options:
- release
- release-debug
description: "release-debug means release with debug info for profile"
- profiling
- ci
description: "profiling means release with debug info for profiling, ci means release with debug info and faster build time"

permissions:
# To publish packages with provenance
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
with:
target: ${{ matrix.array.target }}
runner: ${{ matrix.array.runner }}
profile: "release-prod"
profile: "release"

release:
name: Release
Expand Down
57 changes: 7 additions & 50 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
name: Reusable Release

# Example job:
#jobs
# build:
# strategy:
# matrix:
# array:
# - target: x86_64-unknown-linux-gnu
# runner: ubuntu-latest
# - target: aarch64-unknown-linux-gnu
# runner: ubuntu-latest
# - target: x86_64-unknown-linux-musl
# runner: ubuntu-latest
# - target: aarch64-unknown-linux-musl
# runner: ubuntu-latest
# - target: i686-pc-windows-msvc
# runner: windows-latest
# - target: x86_64-pc-windows-msvc
# runner: windows-latest
# - target: aarch64-pc-windows-msvc
# runner: windows-latest
# - target: x86_64-apple-darwin
# runner: macos-latest
# - target: aarch64-apple-darwin
# runner: macos-latest
# uses: ./.github/workflows/reusable-build.yml
# with:
# target: ${{ matrix.array.target }}
# runner: ${{ matrix.array.runner }}

on:
workflow_call:
inputs:
Expand All @@ -42,8 +13,8 @@ on:
runner: # Runner labels
required: true
type: string
profile: # Rust profile, "debug" or "release"
default: "release"
profile: # Rust profile, "ci" or "production" or "profiling"
default: "ci"
required: false
type: string
test: # Run tests?
Expand Down Expand Up @@ -85,10 +56,6 @@ jobs:
with:
target: ${{ inputs.target }}

- name: Setup tmate session
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48 # v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled && !inputs.skipable }}

- name: Pnpm Cache
if: ${{ !inputs.skipable }}
uses: ./.github/actions/pnpm-cache
Expand All @@ -102,16 +69,6 @@ jobs:
save-cache: ${{ github.ref_name == 'main' }} # This should be safe because we have nightly building the cache every day
shared-key: build-${{ inputs.target }}-${{ inputs.profile }}

# Compile dependencies with optimization to make tests run faster
- name: Add optimization to debug profile
if: ${{ inputs.profile == 'debug' && !inputs.skipable }}
shell: bash
run: |
echo '[profile.release.package."*"]' >> Cargo.toml
echo 'opt-level = 3' >> Cargo.toml
echo 'codegen-units = 64' >> Cargo.toml
echo 'incremental = false' >> Cargo.toml
- name: Trim paths
if: ${{ !inputs.skipable }}
shell: bash
Expand All @@ -122,7 +79,7 @@ jobs:
- name: Check local cache
id: check_cache
if: ${{ inputs.profile == 'debug' && !startsWith(runner.name, 'GitHub Actions') && !inputs.skipable }}
if: ${{ inputs.profile == 'ci' && !startsWith(runner.name, 'GitHub Actions') && !inputs.skipable }}
shell: bash
run: |
set -e
Expand Down Expand Up @@ -227,7 +184,7 @@ jobs:
with:
name: bindings-${{ inputs.target }}
path: crates/node_binding/*.node
try-local-cache: ${{ inputs.profile == 'debug' }}
try-local-cache: ${{ inputs.profile == 'ci' }}
mv-when-local: true

e2e:
Expand All @@ -253,7 +210,7 @@ jobs:
with:
name: bindings-${{ inputs.target }}
path: crates/node_binding/
try-local-cache: ${{ inputs.profile == 'debug' }}
try-local-cache: ${{ inputs.profile == 'ci' }}
link-when-local: true

- name: Setup Pnpm
Expand Down Expand Up @@ -315,7 +272,7 @@ jobs:
with:
name: bindings-${{ inputs.target }}
path: crates/node_binding/
try-local-cache: ${{ inputs.profile == 'debug' }}
try-local-cache: ${{ inputs.profile == 'ci' }}
link-when-local: true

- name: Show restored binding
Expand Down Expand Up @@ -414,7 +371,7 @@ jobs:
with:
name: bindings-${{ inputs.target }}
path: crates/node_binding/
try-local-cache: ${{ inputs.profile == 'debug' }}
try-local-cache: ${{ inputs.profile == 'ci' }}
link-when-local: true

- name: Show restored binding
Expand Down
34 changes: 22 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -195,29 +195,39 @@ rspack_util = { version = "0.2.0", path = "crates/rsp

[workspace.metadata.release]
rate-limit = { existing-packages = 70, new-packages = 70 }

# Follow servo's style https://github.com/servo/servo/blob/c95bd9d052d7eae378d31c5be0f92669cadb2c85/Cargo.toml#L175

# This is for local development
[profile.dev]
codegen-units = 16
debug = 2 # debug build will cause runtime panic if codegen-unints is default
incremental = true
panic = "abort"
debug = 2 # debug build will cause runtime panic if codegen-unints is default
incremental = true
panic = "abort"

# This is for release build for users
[profile.release]
codegen-units = 1
debug = false
# Performs “thin” LTO. This is similar to “fat”, but takes substantially less time to run while still achieving performance gains similar to “fat”.
lto = "thin"
opt-level = 3
# Performs “fat” LTO which attempts to perform optimizations across all crates within the dependency graph.
lto = "fat"
opt-level = "s"
panic = "abort"
strip = true

[profile.release-prod]
inherits = "release"
# Performs “fat” LTO which attempts to perform optimizations across all crates within the dependency graph.
lto = "fat"
# This is for CI build based on release but with faster build time
[profile.ci]
codegen-units = 64
inherits = "release"
## reduce little optimization to reduce build time
lto = "thin"
## reduce little optimization to reduce build time
opt-level = 2

[profile.release-debug]
# This is for production for profiling production build
[profile.profiling]
debug = true
inherits = "release"
lto = "thin"
strip = false

# the following lints rules are from https://github.com/biomejs/biome/blob/4bd3d6f09642952ee14445ed56af81a73796cea1/Cargo.toml#L7C1-L75C1
Expand Down
22 changes: 4 additions & 18 deletions crates/node_binding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,10 @@
"binding.d.ts"
],
"scripts": {
"build:debug": "node scripts/build.js",
"watch:debug": "node scripts/build.js --watch",
"build:debug:x64": "cross-env RUST_TARGET=x86_64-apple-darwin node scripts/build.js",
"build:debug:linux": "cross-env RUST_TARGET=x86_64-unknown-linux-gnu node scripts/build.js",
"build:release": "node scripts/build.js --release",
"watch:release": "node scripts/build.js --release --watch",
"build:release:arm64": "cross-env RUST_TARGET=aarch64-apple-darwin node scripts/build.js --release",
"build:release:x64": "cross-env RUST_TARGET=x86_64-apple-darwin node scripts/build.js --release",
"build:release:linux": "cross-env RUST_TARGET=x86_64-unknown-linux-gnu node scripts/build.js --release",
"build:release:musl": "cross-env RUST_TARGET=aarch64-unknown-linux-musl node scripts/build.js --release",
"build:release:win": "cross-env RUST_TARGET=x86_64-pc-windows-msvc node scripts/build.js --release",
"build:release-prod": "node scripts/build.js --release-prod",
"watch:release-prod": "node scripts/build.js --release-prod --watch",
"build:release-prod:arm64": "cross-env RUST_TARGET=aarch64-apple-darwin node scripts/build.js --release-prod",
"build:release-prod:x64": "cross-env RUST_TARGET=x86_64-apple-darwin node scripts/build.js --release-prod",
"build:release-prod:linux": "cross-env RUST_TARGET=x86_64-unknown-linux-gnu node scripts/build.js --release-prod",
"build:release-prod:win": "cross-env RUST_TARGET=x86_64-pc-windows-msvc node scripts/build.js --release-prod",
"build:release-debug": "node scripts/build.js --release-debug",
"build:dev": "node scripts/build.js",
"build:ci": "node scripts/build.js --profile ci",
"build:production": "node scripts/build.js --profile production",
"build:release": "node scripts/build.js --profile release",
"move-binding": "node scripts/move-binding",
"test": "tsc -p tsconfig.type-test.json"
},
Expand Down
23 changes: 10 additions & 13 deletions crates/node_binding/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
const path = require("path");
const { readFileSync, writeFileSync } = require("fs")
const { values } = require('util').parseArgs({
args: process.argv.slice(2),
options: {
profile: {
type: 'string'
}
}
})

const { spawn } = require("child_process");

const CARGO_SAFELY_EXIT_CODE = 0;

// Faster release for CI & canary with `thin` LTO
let release = process.argv.includes("--release");
// Slower release for production with `fat` LTO
let releaseProd = process.argv.includes("--release-prod");
let releaseDebug = process.argv.includes("--release-debug");
let watch = process.argv.includes("--watch");

build().then((value) => {
Expand All @@ -35,14 +38,8 @@ async function build() {
"--pipe",
`"node ./scripts/dts-header.js"`
];
if (release) {
args.push("--release");
}
if (releaseProd) {
args.push('--profile release-prod');
}
if (releaseDebug) {
args.push('--profile release-debug');
if (values.profile) {
args.push("--profile", values.profile)
}
if (watch) {
args.push("--watch");
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"clean": "pnpm --filter @rspack/cli run clean",
"check-dependency-version": "pnpx check-dependency-version-consistency@5 . --ignore-dep @napi-rs/cli --ignore-dep chalk --ignore-package webpack-test --ignore-package webpack-examples --ignore-package plugin-test",
"build:js": "pnpm --filter \"@rspack/core\" build:force && pnpm --filter \"@rspack/*\" --filter \"create-rspack\" --filter \"!@rspack/core\" build",
"build:cli:debug": "npm run build:binding:debug && npm run build:js",
"build:cli:dev": "npm run build:binding:dev && npm run build:js",
"build:cli:release": "npm run build:binding:release && npm run build:js",
"build:cli:release:all": "pnpm --filter @rspack/binding build:release:all && npm run build:js",
"build:cli:release:arm64": "pnpm --filter @rspack/binding build:release:arm64 && npm run build:js",
Expand All @@ -28,10 +28,10 @@
"lint:js": "pnpm run lint-ci:js --write",
"lint-ci:js": "biome check --diagnostic-level=warn --no-errors-on-unmatched --max-diagnostics=none",
"lint:rs": "node ./scripts/check_rust_dependency.cjs",
"build:binding:debug": "pnpm --filter @rspack/binding run build:debug",
"build:binding:dev": "pnpm --filter @rspack/binding run build:dev",
"build:binding:ci": "pnpm --filter @rspack/binding run build:ci",
"build:binding:release": "pnpm --filter @rspack/binding run build:release",
"build:binding:release-debug": "pnpm --filter @rspack/binding run build:release-debug",
"build:binding:release-prod": "pnpm --filter @rspack/binding run build:release-prod",
"build:binding:profiling": "pnpm --filter @rspack/binding run build:profiling",
"prepare": "is-ci || husky",
"test:diff": "pnpm --filter \"@rspack/*\" test:diff",
"test:hot": "pnpm --filter \"@rspack/*\" test:hot",
Expand All @@ -43,7 +43,8 @@
"doc-coverage": "pnpm --filter \"@rspack/core\" doc-coverage",
"api-extractor:local": "pnpm --filter \"@rspack/*\" api-extractor --local",
"api-extractor:ci": "pnpm --filter \"@rspack/*\" api-extractor:ci",
"bench:ci": "cargo codspeed run && pnpm --filter bench run bench"
"bench:ci:rust": "cargo codspeed run",
"bench:ci:js": "pnpm --filter bench run bench"
},
"homepage": "https://rspack.dev",
"bugs": "https://github.com/web-infra-dev/rspack/issues",
Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/contribute/development/debugging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ To illustrate this process, I'll use an example. Let's start by introduce the en
Firstly, you need to build rspack in debug mode. To do this, execute the following commands in the project's root directory:

```bash
npm run build:binding:debug
npm run build:binding:dev
npm run build:js
```

Expand Down
2 changes: 1 addition & 1 deletion website/docs/zh/contribute/development/debugging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Target 0: (node) stopped.
首先,你需要在调试模式下构建 rspack。为此,请在项目的根目录中执行以下命令:

```bash
npm run build:binding:debug
npm run build:binding:dev
npm run build:js
```

Expand Down
2 changes: 1 addition & 1 deletion x.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ buildCommand
.command("binding")
.description("build rust binding")
.action(async () => {
await $`pnpm --filter @rspack/binding build:debug`;
await $`pnpm --filter @rspack/binding build:dev`;
});

// x build js
Expand Down

2 comments on commit 5458f29

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on 5458f29 Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2025-02-14 05524cd) Current Change
10000_big_production-mode_disable-minimize + exec 37.9 s ± 263 ms 39.3 s ± 454 ms +3.81 %
10000_development-mode + exec 1.83 s ± 21 ms 1.88 s ± 61 ms +2.31 %
10000_development-mode_hmr + exec 680 ms ± 7.1 ms 687 ms ± 3.1 ms +0.94 %
10000_production-mode + exec 2.29 s ± 68 ms 2.35 s ± 139 ms +2.90 %
10000_production-mode_persistent-cold + exec 2.44 s ± 66 ms 2.47 s ± 74 ms +1.15 %
10000_production-mode_persistent-hot + exec 1.68 s ± 135 ms 1.71 s ± 216 ms +1.78 %
arco-pro_development-mode + exec 1.8 s ± 164 ms 1.8 s ± 284 ms +0.09 %
arco-pro_development-mode_hmr + exec 388 ms ± 1.9 ms 388 ms ± 2.9 ms +0.07 %
arco-pro_production-mode + exec 3.6 s ± 123 ms 3.67 s ± 202 ms +1.98 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.63 s ± 134 ms 3.69 s ± 201 ms +1.61 %
arco-pro_production-mode_persistent-cold + exec 3.79 s ± 176 ms 3.86 s ± 171 ms +2.04 %
arco-pro_production-mode_persistent-hot + exec 2.37 s ± 75 ms 2.41 s ± 145 ms +1.85 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.62 s ± 183 ms 3.69 s ± 133 ms +1.95 %
large-dyn-imports_development-mode + exec 2.12 s ± 18 ms 2.14 s ± 40 ms +1.13 %
large-dyn-imports_production-mode + exec 2.15 s ± 48 ms 2.19 s ± 36 ms +1.61 %
threejs_development-mode_10x + exec 1.58 s ± 69 ms 1.56 s ± 62 ms -1.34 %
threejs_development-mode_10x_hmr + exec 785 ms ± 7.9 ms 772 ms ± 8.6 ms -1.58 %
threejs_production-mode_10x + exec 5.25 s ± 50 ms 5.25 s ± 99 ms +0.06 %
threejs_production-mode_10x_persistent-cold + exec 5.31 s ± 95 ms 5.4 s ± 247 ms +1.75 %
threejs_production-mode_10x_persistent-hot + exec 4.52 s ± 102 ms 4.56 s ± 182 ms +0.85 %
10000_big_production-mode_disable-minimize + rss memory 8704 MiB ± 49.5 MiB 8723 MiB ± 71.3 MiB +0.22 %
10000_development-mode + rss memory 636 MiB ± 27.9 MiB 649 MiB ± 45 MiB +1.89 %
10000_development-mode_hmr + rss memory 1223 MiB ± 158 MiB 1226 MiB ± 206 MiB +0.30 %
10000_production-mode + rss memory 628 MiB ± 14.1 MiB 628 MiB ± 19.6 MiB +0.01 %
10000_production-mode_persistent-cold + rss memory 735 MiB ± 12.5 MiB 737 MiB ± 14.8 MiB +0.29 %
10000_production-mode_persistent-hot + rss memory 719 MiB ± 3.87 MiB 713 MiB ± 15.9 MiB -0.83 %
arco-pro_development-mode + rss memory 583 MiB ± 24.4 MiB 578 MiB ± 37.8 MiB -0.86 %
arco-pro_development-mode_hmr + rss memory 644 MiB ± 77 MiB 651 MiB ± 62.8 MiB +0.99 %
arco-pro_production-mode + rss memory 724 MiB ± 7.62 MiB 712 MiB ± 31 MiB -1.72 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 728 MiB ± 15.8 MiB 735 MiB ± 48.8 MiB +0.98 %
arco-pro_production-mode_persistent-cold + rss memory 843 MiB ± 21.6 MiB 854 MiB ± 33 MiB +1.26 %
arco-pro_production-mode_persistent-hot + rss memory 710 MiB ± 22.1 MiB 710 MiB ± 22.2 MiB -0.04 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 709 MiB ± 8.18 MiB 729 MiB ± 20.9 MiB +2.75 %
large-dyn-imports_development-mode + rss memory 643 MiB ± 3.77 MiB 642 MiB ± 3.28 MiB -0.11 %
large-dyn-imports_production-mode + rss memory 525 MiB ± 6.6 MiB 527 MiB ± 4.28 MiB +0.33 %
threejs_development-mode_10x + rss memory 552 MiB ± 18.3 MiB 545 MiB ± 18.9 MiB -1.23 %
threejs_development-mode_10x_hmr + rss memory 1105 MiB ± 90.1 MiB 1131 MiB ± 153 MiB +2.37 %
threejs_production-mode_10x + rss memory 841 MiB ± 33 MiB 829 MiB ± 40.8 MiB -1.35 %
threejs_production-mode_10x_persistent-cold + rss memory 968 MiB ± 36.3 MiB 954 MiB ± 60.8 MiB -1.42 %
threejs_production-mode_10x_persistent-hot + rss memory 866 MiB ± 43.1 MiB 861 MiB ± 43.4 MiB -0.61 %

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on 5458f29 Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ecosystem CI detail: Open

suite result
modernjs ✅ success
rspress ✅ success
rslib ✅ success
rsbuild ❌ failure
rsdoctor ❌ failure
examples ✅ success
devserver ✅ success
nuxt ✅ success

Please sign in to comment.