Skip to content

Conversation

workingjubilee
Copy link
Member

The new Lru type, as a single-purpose "ArrayVec",

  • removes a level of indirection
  • omits a needless Vec allocation entirely
  • internalizes invariants we attempted to maintain in open-coded form

It costs a little unsafe to handle Drop, which we unfortunately need as addr2line uses Arc inside Context.

The new Lru type, as a single-purpose "ArrayVec",
- removes a level of indirection
- omits a needless Vec allocation entirely
- internalizes invariants we attempted to maintain in open-coded form

It costs a little `unsafe` to handle Drop, which we unfortunately need
as addr2line uses Arc inside Context.
Copy link
Contributor

github-actions bot commented Jan 4, 2025

Code size changes for a hello-world Rust program linked with libstd with backtrace:

On platform ubuntu-latest:

  • Original binary size: 383,480 B
  • Updated binary size: 373,512 B
  • Difference: -9,968 B (-2.6%)

Copy link
Member Author

@workingjubilee workingjubilee left a comment

Choose a reason for hiding this comment

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

hell yeah!

Copy link
Contributor

github-actions bot commented Jan 4, 2025

Code size changes for a hello-world Rust program linked with libstd with backtrace:

On platform ubuntu-latest:

  • Original binary size: 383,480 B
  • Updated binary size: 373,512 B
  • Difference: -9,968 B (-2.6%)

Copy link
Contributor

github-actions bot commented Jan 4, 2025

Code size changes for a hello-world Rust program linked with libstd with backtrace:

On platform ubuntu-latest:

  • Original binary size: 383,480 B
  • Updated binary size: 373,512 B
  • Difference: -9,968 B (-2.6%)

let len = self.len;
self.len = 0;
// SAFETY: we can't touch these values again due to setting self.len = 0
unsafe { ptr::drop_in_place(ptr::addr_of_mut!(self.arr[0..len]) as *mut [T]) }
Copy link
Member

Choose a reason for hiding this comment

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

cast still requires sized, shame.

Copy link
Contributor

github-actions bot commented Jan 4, 2025

Code size changes for a hello-world Rust program linked with libstd with backtrace:

On platform ubuntu-latest:

  • Original binary size: 383,480 B
  • Updated binary size: 385,800 B
  • Difference: 2,320 B (0.6%)

@workingjubilee
Copy link
Member Author

...
@ChrisDenton apparently it optimizes worse?

@ChrisDenton
Copy link
Member

Yeah ok, no idea what that's about but revering back to replace makes sense. Maybe with a comment saying why.

Copy link
Contributor

github-actions bot commented Jan 4, 2025

Code size changes for a hello-world Rust program linked with libstd with backtrace:

On platform ubuntu-latest:

  • Original binary size: 383,480 B
  • Updated binary size: 373,512 B
  • Difference: -9,968 B (-2.6%)

Copy link
Member

@ChrisDenton ChrisDenton left a comment

Choose a reason for hiding this comment

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

This is such a nice improvement, thanks!

@ChrisDenton ChrisDenton merged commit d7c5a45 into rust-lang:master Jan 4, 2025
41 checks passed
@workingjubilee workingjubilee deleted the formalize-lru branch January 4, 2025 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants