Skip to content

Conversation

@MikeMcQuaid
Copy link
Member

Not including this globally in Pathname speeds up the creation of other Pathname objects by ~200x making all of Homebrew faster.

Copilot AI review requested due to automatic review settings November 14, 2025 18:16
Copilot finished reviewing on behalf of MikeMcQuaid November 14, 2025 18:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes Homebrew's performance by removing the global inclusion of MachOShim and ELFShim in the Pathname class. Instead, these modules are now explicitly extended only when needed on individual Pathname instances, resulting in ~200x faster Pathname object creation.

  • Removed global MachOShim/ELFShim inclusion from Pathname class
  • Updated code to explicitly extend Pathname instances with MachOShim or ELFShim where binary file operations are needed
  • Restructured Linux cleaner module to match the Mac cleaner pattern with proper namespacing

Reviewed Changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Library/Homebrew/utils/linkage.rb Added explicit extension of Pathname with OS-specific shims before checking dynamic libraries
Library/Homebrew/test/support/helper/fixtures.rb Added explicit MachOShim extension to test fixture paths
Library/Homebrew/test/os/mac/mach_spec.rb Added explicit MachOShim extension to test pathnames
Library/Homebrew/extend/pathname.rb Removed global OS-specific pathname extension require
Library/Homebrew/extend/os/pathname.rb Deleted file that globally included OS-specific pathname extensions
Library/Homebrew/extend/os/mac/keg_relocate.rb Added explicit MachOShim extension before checking Mach-O file properties
Library/Homebrew/extend/os/mac/extend/pathname.rbi Deleted type signature file for global MachOShim inclusion
Library/Homebrew/extend/os/mac/extend/pathname.rb Deleted file that globally prepended MachOShim to Pathname
Library/Homebrew/extend/os/mac/cleaner.rb Added explicit MachOShim extension before checking if path is a Mach-O executable
Library/Homebrew/extend/os/linux/keg_relocate.rb Added explicit ELFShim extension before checking ELF file properties
Library/Homebrew/extend/os/linux/extend/pathname.rbi Deleted type signature file for global ELFShim inclusion
Library/Homebrew/extend/os/linux/extend/pathname.rb Deleted file that globally prepended ELFShim to Pathname
Library/Homebrew/extend/os/linux/cleaner.rb Restructured into OS::Linux::Cleaner module and added explicit ELFShim extension
Files not reviewed (2)
  • Library/Homebrew/extend/os/linux/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/os/mac/extend/pathname.rbi: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@Rylan12 Rylan12 left a comment

Choose a reason for hiding this comment

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

Nice, makes sense to me once CI/copilot comments are resolved!

@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 8f53c75 to 3a383ab Compare November 16, 2025 14:08
Copilot AI review requested due to automatic review settings November 17, 2025 09:06
@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 3a383ab to 7cbd1ce Compare November 17, 2025 09:06
Copilot finished reviewing on behalf of MikeMcQuaid November 17, 2025 09:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 25 out of 27 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • Library/Homebrew/extend/os/linux/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/os/mac/extend/pathname.rbi: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@Rylan12 Rylan12 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 a really nice improvement!

@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 7cbd1ce to 88d171e Compare November 17, 2025 20:35
Copilot AI review requested due to automatic review settings November 18, 2025 09:28
@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 88d171e to cab671f Compare November 18, 2025 09:28
Copilot finished reviewing on behalf of MikeMcQuaid November 18, 2025 09:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 26 out of 28 changed files in this pull request and generated 4 comments.

Files not reviewed (2)
  • Library/Homebrew/extend/os/linux/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/os/mac/extend/pathname.rbi: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from cab671f to 17824a4 Compare November 18, 2025 09:35
Copilot AI review requested due to automatic review settings November 18, 2025 09:45
@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 17824a4 to 9f19617 Compare November 18, 2025 09:45
Copilot finished reviewing on behalf of MikeMcQuaid November 18, 2025 09:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 26 out of 28 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • Library/Homebrew/extend/os/linux/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/os/mac/extend/pathname.rbi: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 9f19617 to bad399a Compare November 18, 2025 14:22
Copilot AI review requested due to automatic review settings November 18, 2025 14:59
@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from bad399a to 309e32d Compare November 18, 2025 14:59
Copilot finished reviewing on behalf of MikeMcQuaid November 18, 2025 15:02
@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 7c765d9 to 3c3bb32 Compare November 28, 2025 16:52
Copilot finished reviewing on behalf of MikeMcQuaid November 28, 2025 16:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 54 out of 57 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • Library/Homebrew/extend/os/linux/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/os/mac/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/pathname.rbi: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 3c3bb32 to b7dab0d Compare November 28, 2025 16:57
Copilot AI review requested due to automatic review settings November 28, 2025 17:14
@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from b7dab0d to 1a95c12 Compare November 28, 2025 17:14
Copilot finished reviewing on behalf of MikeMcQuaid November 28, 2025 17:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 54 out of 57 changed files in this pull request and generated no new comments.

Files not reviewed (3)
  • Library/Homebrew/extend/os/linux/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/os/mac/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/pathname.rbi: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 1a95c12 to 3c74725 Compare November 28, 2025 19:08
Copilot AI review requested due to automatic review settings November 28, 2025 19:18
@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 3c74725 to 055fe68 Compare November 28, 2025 19:18
@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 055fe68 to c02be20 Compare November 28, 2025 19:20
Copilot finished reviewing on behalf of MikeMcQuaid November 28, 2025 19:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 54 out of 57 changed files in this pull request and generated no new comments.

Files not reviewed (3)
  • Library/Homebrew/extend/os/linux/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/os/mac/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/pathname.rbi: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from c02be20 to 73b6aa7 Compare November 28, 2025 19:34
Not including this globally in `Pathname` speeds up the creation of
other `Pathname` objects by ~200x making all of Homebrew faster.
Copilot AI review requested due to automatic review settings November 29, 2025 10:31
@MikeMcQuaid MikeMcQuaid force-pushed the mach_elf_optional_shim branch from 73b6aa7 to bd4eb5e Compare November 29, 2025 10:31
Copilot finished reviewing on behalf of MikeMcQuaid November 29, 2025 10:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 54 out of 57 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • Library/Homebrew/extend/os/linux/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/os/mac/extend/pathname.rbi: Language not supported
  • Library/Homebrew/extend/pathname.rbi: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Nov 29, 2025
Merged via the queue into main with commit a766abe Nov 29, 2025
48 checks passed
@MikeMcQuaid MikeMcQuaid deleted the mach_elf_optional_shim branch November 29, 2025 11:05
@MikeMcQuaid
Copy link
Member Author

Maintainers: this shouldn't break anything but, if it does, it should be fairly simple to use MachOPathname.wrap (for macOS-only code) or ELFPathname.wrap (for Linux-only code) or BinaryPathname.wrap (otherwise).

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.

3 participants