Skip to content

refactor(allocator): InnerVec use Alloc trait#11199

Merged
graphite-app[bot] merged 1 commit intomainfrom
05-20-refactor_allocator_innervec_use_alloc_trait
May 21, 2025
Merged

refactor(allocator): InnerVec use Alloc trait#11199
graphite-app[bot] merged 1 commit intomainfrom
05-20-refactor_allocator_innervec_use_alloc_trait

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented May 20, 2025

Parameterize InnerVec (otherwise known as Vec2) and RawVec with Alloc trait introduced in #11198.

InnerVec and RawVec no longer have a dependency on bumpalo::Bump. The rationale for that is discussed in #11198.

The only substantive change this PR makes is that all Alloc methods panic/abort if allocation fails, rather than returning a Result::Err. This alters the behavior of try_* methods, which previously wouldn't panic. However, I don't believe we use any of those methods, and we have no plans to, so in my view we should remove them. In practice it should be very difficult to exhaust all memory, and if we did there's no way to gracefully recover from that (what would we do? only parse half the file?). So this has little/no practical impact.

That apart, this PR is pure refactor. The diff is large, but it's almost entirely adding the A: Alloc bound to all methods / iterators, and removing Bump.

@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label May 20, 2025
Copy link
Member Author

overlookmotel commented May 20, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented May 20, 2025

CodSpeed Instrumentation Performance Report

Merging #11199 will create unknown performance changes

Comparing 05-20-refactor_allocator_innervec_use_alloc_trait (6827543) with 05-20-feat_allocator_introduce_alloc_trait (a2ab84b)

Summary

🆕 38 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 codegen[RadixUIAdoptionSection.jsx] N/A 132.3 µs N/A
🆕 codegen[binder.ts] N/A 4.8 ms N/A
🆕 codegen[cal.com.tsx] N/A 38.9 ms N/A
🆕 codegen[react.development.js] N/A 2.2 ms N/A
🆕 formatter[RadixUIAdoptionSection.jsx] N/A 299.5 µs N/A
🆕 formatter[binder.ts] N/A 15.8 ms N/A
🆕 formatter[cal.com.tsx] N/A 128.1 ms N/A
🆕 formatter[react.development.js] N/A 8.1 ms N/A
🆕 lexer[RadixUIAdoptionSection.jsx] N/A 21.9 µs N/A
🆕 lexer[binder.ts] N/A 961.2 µs N/A
🆕 lexer[cal.com.tsx] N/A 6 ms N/A
🆕 lexer[react.development.js] N/A 397.3 µs N/A
🆕 linter[RadixUIAdoptionSection.jsx] N/A 2.8 ms N/A
🆕 linter[binder.ts] N/A 149 ms N/A
🆕 linter[cal.com.tsx] N/A 1.3 s N/A
🆕 linter[react.development.js] N/A 54.7 ms N/A
🆕 mangler[RadixUIAdoptionSection.jsx] N/A 14 µs N/A
🆕 mangler[binder.ts] N/A 797.9 µs N/A
🆕 mangler[cal.com.tsx] N/A 3 ms N/A
🆕 mangler[react.development.js] N/A 283.2 µs N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@overlookmotel overlookmotel marked this pull request as ready for review May 20, 2025 22:38
@overlookmotel overlookmotel force-pushed the 05-20-refactor_allocator_innervec_use_alloc_trait branch 2 times, most recently from d3495e1 to 8937f64 Compare May 20, 2025 22:55
@overlookmotel
Copy link
Member Author

There's a small perf regression on a few benchmarks. I propose that we don't worry about it. Once we remove Result from signature of all methods in Vec, it'll be recovered.

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label May 21, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented May 21, 2025

Merge activity

Parameterize `InnerVec` (otherwise known as `Vec2`) and `RawVec` with `Alloc` trait introduced in #11198.

`InnerVec` and `RawVec` no longer have a dependency on `bumpalo::Bump`. The rationale for that is discussed in #11198.

The only substantive change this PR makes is that all `Alloc` methods panic/abort if allocation fails, rather than returning a `Result::Err`. This alters the behavior of `try_*` methods, which previously wouldn't panic. However, I don't believe we use any of those methods, and we have no plans to, so in my view we should remove them. In practice it should be very difficult to exhaust all memory, and if we did there's no way to gracefully recover from that (what would we do? only parse half the file?). So this has little/no practical impact.

That apart, this PR is pure refactor. The diff is large, but it's almost entirely adding the `A: Alloc` bound to all methods / iterators, and removing `Bump`.
@graphite-app graphite-app bot force-pushed the 05-20-feat_allocator_introduce_alloc_trait branch from 69ca688 to a2ab84b Compare May 21, 2025 00:42
@graphite-app graphite-app bot force-pushed the 05-20-refactor_allocator_innervec_use_alloc_trait branch from 8937f64 to 6827543 Compare May 21, 2025 00:43
Base automatically changed from 05-20-feat_allocator_introduce_alloc_trait to main May 21, 2025 00:49
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 21, 2025
@graphite-app graphite-app bot merged commit 6827543 into main May 21, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 05-20-refactor_allocator_innervec_use_alloc_trait branch May 21, 2025 00:50
graphite-app bot pushed a commit that referenced this pull request May 22, 2025
Follow-on after #11199. Pure refactor. In `Vec`, use a type alias for `InnerVec`, instead of specifying `InnerVec<'a, T, Bump>` in multiple places.

This makes the dependency on `bumpalo::Bump` be on just 1 line, which is tidier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants