Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Tap#cask_files_by_name. #16775

Merged
merged 1 commit into from Mar 1, 2024
Merged

Conversation

reitermarkus
Copy link
Member

@reitermarkus reitermarkus commented Feb 29, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Extracted from #16730 for easier review.

Copy link
Contributor

@apainintheneck apainintheneck left a comment

Choose a reason for hiding this comment

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

Yeah, I've been wondering about this one too. Happy to see this get cleaned up.

@@ -588,8 +588,7 @@ def self.default_path(token)
def self.find_cask_in_tap(token, tap)
filename = "#{token}.rb"

Tap.cask_files_by_name(tap)
.fetch(token, tap.cask_dir/filename)
tap.cask_files_by_name.fetch(token, tap.cask_dir/filename)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
tap.cask_files_by_name.fetch(token, tap.cask_dir/filename)
tap.cask_files_by_name.fetch(token) { tap.cask_dir/filename }

Nit: You could use a block here to avoid building Pathname objects when the result is in the hash.

Copy link
Member

Choose a reason for hiding this comment

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

@apainintheneck Seems like a good follow-up PR if it has any measurable performance impact.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have any benchmarks to back this up but we have had a lot of performance problems related to creating loads of Pathname objects before. It just seemed like an easy way to avoid that.

Copy link
Member

Choose a reason for hiding this comment

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

@apainintheneck Ok, thanks, will bear that in mind in future.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks again @reitermarkus!

@@ -588,8 +588,7 @@ def self.default_path(token)
def self.find_cask_in_tap(token, tap)
filename = "#{token}.rb"

Tap.cask_files_by_name(tap)
.fetch(token, tap.cask_dir/filename)
tap.cask_files_by_name.fetch(token, tap.cask_dir/filename)
Copy link
Member

Choose a reason for hiding this comment

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

@apainintheneck Seems like a good follow-up PR if it has any measurable performance impact.

@MikeMcQuaid MikeMcQuaid merged commit 98f6ab2 into Homebrew:master Mar 1, 2024
26 checks passed
apainintheneck added a commit that referenced this pull request Mar 2, 2024
We essentially stopped caching these accidentally and they get
called every time we try to load a cask or formula from the API.
It gets really, really, really slow.

I ran `brew deps --casks --eval-all` before and after the changes.

I let it run for 3 minutes before killing it. No output had been
printed to the screen.

It finished printing all output (pages and pages of it) in less
than a minute.

---

This should match the caching behavior we had before the
recent changes in these two PRs.

- #16777
- #16775
@reitermarkus reitermarkus deleted the tap-sig-2 branch March 2, 2024 13:40
@github-actions github-actions bot added the outdated PR was locked due to age label Apr 3, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants