Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented May 16, 2025

Simplify Vec::truncate and Vec::extend_with methods.

Unlike standard library, our Vec<'a, T> requires that T is not Drop. Therefore we don't need to worry about dropping elements.

There are likely many more places where we can make similar simplifications (optimizations). I've only done these 2 now in order to get rid of SetLenOnDrop. I wanted to get rid of it because it requires direct access to self.buf.len, which I'd like to make private in a later PR.

Copy link
Member Author

overlookmotel commented May 16, 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.

@overlookmotel overlookmotel marked this pull request as ready for review May 16, 2025 13:34
@codspeed-hq
Copy link

codspeed-hq bot commented May 16, 2025

CodSpeed Instrumentation Performance Report

Merging #11079 will not alter performance

Comparing 05-16-perf_allocator_vec_remove_setlenondrop_ (a6057c7) with main (f0b76e8)

Summary

✅ 36 untouched benchmarks

Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

Looks good! Your comments let me know better what SetLenOnDrop is going on.

Copy link
Member Author

overlookmotel commented May 17, 2025

Merge activity

@graphite-app graphite-app bot changed the base branch from 05-16-refactor_allocator_vec_limit_scope_of_expect_clippy_cast_possible_truncation_ to graphite-base/11079 May 17, 2025 10:17
@graphite-app graphite-app bot force-pushed the graphite-base/11079 branch from 290ae50 to 2f05c54 Compare May 17, 2025 10:25
@graphite-app graphite-app bot force-pushed the 05-16-perf_allocator_vec_remove_setlenondrop_ branch from 4bf146c to b239cb0 Compare May 17, 2025 10:25
@graphite-app graphite-app bot changed the base branch from graphite-base/11079 to main May 17, 2025 10:25
@graphite-app graphite-app bot force-pushed the 05-16-perf_allocator_vec_remove_setlenondrop_ branch from b239cb0 to 6a14896 Compare May 17, 2025 10:25
@overlookmotel
Copy link
Member Author

I'll fix the Miri fail. It appears not to be due to Miri flagging UB, but due to lint errors which have been added on nightly.

@overlookmotel
Copy link
Member Author

overlookmotel commented May 17, 2025

Miri fail was unrelated. Fixed in #11092.

@overlookmotel overlookmotel force-pushed the 05-16-perf_allocator_vec_remove_setlenondrop_ branch from 6a14896 to cfad6c4 Compare May 17, 2025 12:05
Simplify `Vec::truncate` and `Vec::extend_with` methods.

Unlike standard library, our `Vec<'a, T>` requires that `T` is not `Drop`. Therefore we don't need to worry about dropping elements.

There are likely many more places where we can make similar simplifications (optimizations). I've only done these 2 now in order to get rid of `SetLenOnDrop`. I wanted to get rid of it because it requires direct access to `self.buf.len`, which I'd like to make private in a later PR.
@graphite-app graphite-app bot force-pushed the 05-16-perf_allocator_vec_remove_setlenondrop_ branch from cfad6c4 to a6057c7 Compare May 17, 2025 14:52
@graphite-app graphite-app bot merged commit a6057c7 into main May 17, 2025
26 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 17, 2025
@graphite-app graphite-app bot deleted the 05-16-perf_allocator_vec_remove_setlenondrop_ branch May 17, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants