Skip to content

feat(allocator/vec2): introduce extend_desugared method as extend internal implementation#10670

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-28-feat_allocator_vec2_introduce_extend_desugared_method_as_extend_internal_implementation
May 3, 2025
Merged

feat(allocator/vec2): introduce extend_desugared method as extend internal implementation#10670
graphite-app[bot] merged 1 commit intomainfrom
04-28-feat_allocator_vec2_introduce_extend_desugared_method_as_extend_internal_implementation

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Apr 28, 2025

Align extend implementation with the standard library, since the ExtendTrusted is still unstable, so I haven't introduced the extend_trusted yet. Some of the benchmark performance regression has been almost fixed in #10675.

Copy link
Member Author

Dunqing commented Apr 28, 2025

@github-actions github-actions bot added the C-enhancement Category - New feature or request label Apr 28, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 28, 2025

CodSpeed Instrumentation Performance Report

Merging #10670 will not alter performance

Comparing 04-28-feat_allocator_vec2_introduce_extend_desugared_method_as_extend_internal_implementation (6ce3bbb) with main (eb3f37c)

Summary

✅ 36 untouched benchmarks

@Dunqing Dunqing force-pushed the 04-28-feat_allocator_vec2_introduce_extend_desugared_method_as_extend_internal_implementation branch from 92d4255 to 1e4bc1b Compare April 28, 2025 14:39
@Dunqing Dunqing changed the base branch from 04-28-perf_transformer_refresh_use_take_take_in_instead_of_drain to graphite-base/10670 April 29, 2025 02:32
@Dunqing Dunqing force-pushed the 04-28-feat_allocator_vec2_introduce_extend_desugared_method_as_extend_internal_implementation branch from 1e4bc1b to ef784ca Compare April 29, 2025 02:38
@Dunqing Dunqing force-pushed the graphite-base/10670 branch from 3648471 to c01878f Compare April 29, 2025 02:38
@Dunqing Dunqing changed the base branch from graphite-base/10670 to 04-28-perf_transformer_refresh_use_take_take_in_instead_of_drain April 29, 2025 02:38
@Dunqing Dunqing requested a review from overlookmotel April 29, 2025 09:34
@Dunqing Dunqing marked this pull request as ready for review April 29, 2025 15:48
@graphite-app graphite-app bot force-pushed the 04-28-perf_transformer_refresh_use_take_take_in_instead_of_drain branch 2 times, most recently from 58652a1 to 25f8411 Compare April 29, 2025 16:10
@graphite-app graphite-app bot force-pushed the 04-28-feat_allocator_vec2_introduce_extend_desugared_method_as_extend_internal_implementation branch from ef784ca to e64c52c Compare April 29, 2025 16:10
@graphite-app graphite-app bot changed the base branch from 04-28-perf_transformer_refresh_use_take_take_in_instead_of_drain to graphite-base/10670 April 29, 2025 16:40
@graphite-app graphite-app bot force-pushed the graphite-base/10670 branch from 25f8411 to 7d8efd8 Compare April 30, 2025 00:09
@graphite-app graphite-app bot force-pushed the 04-28-feat_allocator_vec2_introduce_extend_desugared_method_as_extend_internal_implementation branch from e64c52c to 11d0723 Compare April 30, 2025 00:09
@graphite-app graphite-app bot changed the base branch from graphite-base/10670 to main April 30, 2025 00:09
@graphite-app graphite-app bot force-pushed the 04-28-feat_allocator_vec2_introduce_extend_desugared_method_as_extend_internal_implementation branch from 11d0723 to a3d2995 Compare April 30, 2025 00:09
@Dunqing Dunqing force-pushed the 04-28-feat_allocator_vec2_introduce_extend_desugared_method_as_extend_internal_implementation branch 3 times, most recently from 9481aae to 9db9639 Compare April 30, 2025 01:16
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label May 3, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented May 3, 2025

Merge activity

… internal implementation (#10670)

Align `extend` implementation with the standard library, since the `ExtendTrusted` is still unstable, so I haven't introduced the `extend_trusted` yet. Some of the benchmark performance regression has been almost fixed in #10675.
@graphite-app graphite-app bot force-pushed the 04-28-feat_allocator_vec2_introduce_extend_desugared_method_as_extend_internal_implementation branch from 9db9639 to 6ce3bbb Compare May 3, 2025 13:03
@coderabbitai
Copy link

coderabbitai bot commented May 3, 2025

Walkthrough

The implementation of the Extend<T> trait for the Vec<'bump, T> type in the crates/oxc_allocator/src/vec2/mod.rs file was refactored. The logic for extending the vector is now delegated to a new private method named extend_desugared. This new method iterates over the input iterator and, for each element, checks if the vector has reached its capacity. If the capacity is reached, it reserves additional space based on the iterator's lower size hint plus one. Elements are written directly into the buffer using unsafe pointer operations, and the vector's length is incremented after each insertion. The method is annotated with #[track_caller] and is intended to serve as the core implementation for extension operations. The public extend method now calls this new private method. No changes were made to the public API surface apart from the internal delegation.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9db9639 and 6ce3bbb.

📒 Files selected for processing (1)
  • crates/oxc_allocator/src/vec2/mod.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/oxc_allocator/src/vec2/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Benchmark (formatter)
  • GitHub Check: Benchmark (codegen)
  • GitHub Check: Benchmark (minifier)
  • GitHub Check: Benchmark (semantic)
  • GitHub Check: Test wasm32-wasip1-threads
  • GitHub Check: Test (macos-latest)
  • GitHub Check: Benchmark (isolated_declarations)
  • GitHub Check: Benchmark (transformer)
  • GitHub Check: Test NAPI
  • GitHub Check: Test (ubuntu-latest)
  • GitHub Check: Benchmark (parser)
  • GitHub Check: Build Linter Benchmark
  • GitHub Check: Clippy
  • GitHub Check: Conformance
  • GitHub Check: Benchmark (lexer)
  • GitHub Check: Miri
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

graphite-app bot pushed a commit that referenced this pull request May 3, 2025
…marking reserve as `#[cold]` and `#[inline(never)]` (#10675)

I guess the performance regression reason is that the current implementation has more instructions than before. Here to use the lower of `size_hint` to reserve space, which is bloating the loop body. Also, the `for` loop is easier to optimize by the compiler.  `reserve` inside `extend` is rarely taken, so mark it as `#[cold]` and `#[inline(never)]`, which can reduce the instructions in `while` loop. We got a 3%-4% performance improvement in the `minfier`, but the transformer performance did not fully get back to before #10670.

Anyway, I think we can accept the less than 1% performance regression; this change can unblock us from pushing forward the `Vec` improvement; we will get it back in at the end of the stack! See #9856
@graphite-app graphite-app bot merged commit 6ce3bbb into main May 3, 2025
26 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 3, 2025
@graphite-app graphite-app bot deleted the 04-28-feat_allocator_vec2_introduce_extend_desugared_method_as_extend_internal_implementation branch May 3, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants