diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 81e8cf90de8fc..c0d2a6309d44c 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -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 @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6791400d98ac..3129ac4a89401 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/miri.yml b/.github/workflows/miri.yml index 7e5ea8b6ae4f9..2bdf413e2d274 100644 --- a/.github/workflows/miri.yml +++ b/.github/workflows/miri.yml @@ -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 diff --git a/crates/oxc_allocator/src/vec2/mod.rs b/crates/oxc_allocator/src/vec2/mod.rs index 6dbf2116f2e72..07b1179298aa1 100644 --- a/crates/oxc_allocator/src/vec2/mod.rs +++ b/crates/oxc_allocator/src/vec2/mod.rs @@ -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(&mut self, mut f: F) where F: FnMut(&T) -> bool, @@ -2279,13 +2280,30 @@ impl<'a, 'bump, T> IntoIterator for &'a mut Vec<'bump, T> { } impl<'bump, T: 'bump> Extend for Vec<'bump, T> { - #[inline] + #[expect(clippy::inline_always)] + #[inline(always)] fn extend>(&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>(&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)); + } + 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); + } } } }