Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 80 additions & 78 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ jobs:
fail-fast: true
matrix:
component:
- lexer
- parser
# - lexer
# - parser
- transformer
- isolated_declarations
- semantic
# - semantic
- minifier
- codegen
- formatter
# - codegen
# - formatter
# - codegen
# - formatter

steps:
- name: Checkout Branch
Expand Down Expand Up @@ -87,76 +89,76 @@ jobs:
token: ${{ secrets.CODSPEED_TOKEN }}
run: cargo codspeed run

# Build linter benchmark.
# Linter benchmarks are much slower than the rest, so we run each fixture in a separate job.
# But only build the linter benchmark once.
build-linter:
name: Build Linter Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout Branch
uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1

- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
with:
cache-key: benchmark-linter
save-cache: ${{ github.ref_name == 'main' }}

- name: Build benchmark
env:
RUSTFLAGS: "-C debuginfo=1 -C strip=none -g --cfg codspeed"
run: |
cargo build --release -p oxc_benchmark --bench linter \
--no-default-features --features linter --features codspeed
mkdir -p target/codspeed/instrumentation/oxc_benchmark
mv target/release/deps/linter-* target/codspeed/instrumentation/oxc_benchmark
rm target/codspeed/instrumentation/oxc_benchmark/*.d

- name: Upload Binary
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
if-no-files-found: error
name: benchmark-linter
path: ./target/codspeed/instrumentation/oxc_benchmark
retention-days: 1

# Run linter benchmarks. Each fixture in a separate job.
benchmark-linter:
name: Benchmark linter
needs: build-linter
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
fixture:
- 0
- 1

steps:
- name: Checkout Branch
uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1

- name: Download Binary
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: benchmark-linter
path: ./target/codspeed/instrumentation/oxc_benchmark

- name: Fix permission loss
run: |
ls ./target/codspeed/instrumentation/oxc_benchmark
chmod +x ./target/codspeed/instrumentation/oxc_benchmark/*

- name: Install codspeed
uses: taiki-e/install-action@ab3728c7ba6948b9b429627f4d55a68842b27f18 # v2.50.3
with:
tool: cargo-codspeed

- name: Run benchmark
uses: CodSpeedHQ/action@0010eb0ca6e89b80c88e8edaaa07cfe5f3e6664d # v3.5.0
timeout-minutes: 30
env:
FIXTURE: ${{ matrix.fixture }}
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: cargo codspeed run
# # Build linter benchmark.
# # Linter benchmarks are much slower than the rest, so we run each fixture in a separate job.
# # But only build the linter benchmark once.
# build-linter:
# name: Build Linter Benchmark
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Branch
# uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1

# - uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
# with:
# cache-key: benchmark-linter
# save-cache: ${{ github.ref_name == 'main' }}

# - name: Build benchmark
# env:
# RUSTFLAGS: "-C debuginfo=1 -C strip=none -g --cfg codspeed"
# run: |
# cargo build --release -p oxc_benchmark --bench linter \
# --no-default-features --features linter --features codspeed
# mkdir -p target/codspeed/instrumentation/oxc_benchmark
# mv target/release/deps/linter-* target/codspeed/instrumentation/oxc_benchmark
# rm target/codspeed/instrumentation/oxc_benchmark/*.d

# - name: Upload Binary
# uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
# with:
# if-no-files-found: error
# name: benchmark-linter
# path: ./target/codspeed/instrumentation/oxc_benchmark
# retention-days: 1

# # Run linter benchmarks. Each fixture in a separate job.
# benchmark-linter:
# name: Benchmark linter
# needs: build-linter
# runs-on: ubuntu-latest
# strategy:
# fail-fast: true
# matrix:
# fixture:
# - 0
# - 1

# steps:
# - name: Checkout Branch
# uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1

# - name: Download Binary
# uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
# with:
# name: benchmark-linter
# path: ./target/codspeed/instrumentation/oxc_benchmark

# - name: Fix permission loss
# run: |
# ls ./target/codspeed/instrumentation/oxc_benchmark
# chmod +x ./target/codspeed/instrumentation/oxc_benchmark/*

# - name: Install codspeed
# uses: taiki-e/install-action@ab3728c7ba6948b9b429627f4d55a68842b27f18 # v2.50.3
# with:
# tool: cargo-codspeed

# - name: Run benchmark
# uses: CodSpeedHQ/action@0010eb0ca6e89b80c88e8edaaa07cfe5f3e6664d # v3.5.0
# timeout-minutes: 30
# env:
# FIXTURE: ${{ matrix.fixture }}
# with:
# token: ${{ secrets.CODSPEED_TOKEN }}
# run: cargo codspeed run
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ permissions: {}

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
paths-ignore:
- "**/*.md"
- "**/*.yml"
- "!.github/workflows/ci.yml"
- "!.github/actions/clone-submodules/action.yml"
# pull_request:
# types: [opened, synchronize]
# paths-ignore:
# - "**/*.md"
# - "**/*.yml"
# - "!.github/workflows/ci.yml"
# - "!.github/actions/clone-submodules/action.yml"
push:
branches:
- main
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/miri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ permissions: {}

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
paths:
- "crates/oxc_allocator/**"
- "crates/oxc_ast/src/utf8_to_utf16.rs"
- "crates/oxc_ast/src/generated/utf8_to_utf16_converter.rs"
- "crates/oxc_data_structures/**"
- "crates/oxc_parser/**"
- "crates/oxc_traverse/**"
- ".github/workflows/miri.yml"
# pull_request:
# types: [opened, synchronize]
# paths:
# - "crates/oxc_allocator/**"
# - "crates/oxc_ast/src/utf8_to_utf16.rs"
# - "crates/oxc_ast/src/generated/utf8_to_utf16_converter.rs"
# - "crates/oxc_data_structures/**"
# - "crates/oxc_parser/**"
# - "crates/oxc_traverse/**"
# - ".github/workflows/miri.yml"
push:
branches:
- main
Expand Down
30 changes: 24 additions & 6 deletions crates/oxc_allocator/src/vec2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,8 @@ impl<'bump, T: 'bump> Vec<'bump, T> {
/// let mut iter = keep.iter();
/// vec.retain(|_| *iter.next().unwrap());
/// assert_eq!(vec, [2, 3, 5]);
/// ```
#[expect(clippy::inline_always)]
#[inline(always)]
pub fn retain<F>(&mut self, mut f: F)
where
F: FnMut(&T) -> bool,
Expand Down Expand Up @@ -2279,13 +2280,30 @@ impl<'a, 'bump, T> IntoIterator for &'a mut Vec<'bump, T> {
}

impl<'bump, T: 'bump> Extend<T> for Vec<'bump, T> {
#[inline]
#[expect(clippy::inline_always)]
#[inline(always)]
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
let iter = iter.into_iter();
self.reserve(iter.size_hint().0);
self.extend_desugared(iter.into_iter());
}
}

for t in iter {
self.push(t);
impl<'bump, T: 'bump> Vec<'bump, T> {
// leaf method to which various SpecFrom/SpecExtend implementations delegate when
// they have no further optimizations to apply
fn extend_desugared<I: Iterator<Item = T>>(&mut self, mut iterator: I) {
while let Some(element) = iterator.next() {
let len = self.len();
if len == self.buf.cap() {
let (lower, _) = iterator.size_hint();
self.reserve(lower.saturating_add(1));
Comment on lines +2297 to +2298
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

After a hundred experiments, I concluded that this has an impact on performance.

}
unsafe {
ptr::write(self.as_mut_ptr().add(len), element);
// Since next() executes user code which can panic we have to bump the length
// after each step.
// NB can't overflow since we would have had to alloc the address space
self.set_len(len + 1);
}
}
}
}
Expand Down
Loading