8000 Process unchanged __package.rb files on the fast path by elliottt · Pull Request #8838 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Process unchanged __package.rb files on the fast path #8838

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

Merged
merged 6 commits into from
May 8, 2025

Conversation

elliottt
Copy link
Collaborator
@elliottt elliottt commented May 6, 2025

We guard __package.rb file changes from entering the fast path, but we do allow __package.rb edits through if the file hasn't changed. We also filter __package.rb files out of the updated file set before running the pipeline, which can lead to running the fast path on zero files if the update set contained only __package.rb files.

This PR switches the fast path to processing __package.rb files the same as other files in the edit. This allows us to process unmodified package files on the fast path where we would previously have discarded them.

Motivation

Avoiding empty fast path edits.

Test plan

Existing tests.

There were two tests that now fail on the fast path, as the __package.rb files are now processed when they weren't before.

@elliottt elliottt changed the title Process __package.rb files on the fast path Process unchanged __package.rb files on the fast path May 6, 2025
@elliottt elliottt force-pushed the trevor/cache-opened-package-files branch 2 times, most recently from 8670f4c to 1d2c52c Compare May 7, 2025 03:41
@elliottt elliottt marked this pull request as ready for review May 7, 2025 04:05
@elliottt elliottt requested a review from a team as a code owner May 7, 2025 04:05
@elliottt elliottt requested review from jez and removed request for a team May 7, 2025 04:05
auto oldFile = gs->replaceFile(fref, std::move(file));

if (oldFile->isPackage(*gs)) {
packageFiles.emplace_back(fref);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Alternatively: is there harm to always computing the oldFoundHashesForFiles for __package.rb files?

Soon we're going to need to do this anyways, so that we can have __package.rb file edits actually take the fast path.

If there's no harm to computing and ignoring them, it would be nice to start that now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think there's any harm in doing this. I'll experiment with handling package files the same as source files.

@@ -1,4 +1,5 @@
# frozen_string_literal: true
# typed: strict
# disable-fast-path: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like a regression—what's up with this? Shouldn't we fix this instead of making the tests fail?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a regression in that the previous behavior was to not run the fast path at all on these tests, which is why it passed without disable-fast-path before. I'll have a look at the incremental packager to see why these errors don't get raised on that path, but we might want to address this in a follow-up.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The issue is that we don't call findPackages in Packager::runIncremental. Perhaps we should look at moving these errors into validatePackage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The self import error is easy to move to validatePackage, but the redefinition error will require more thought to move to the fast path.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Gotcha. Maybe this doesn't matter right now because these errors are so rare. I'll keep it in mind.

@elliottt elliottt force-pushed the trevor/cache-opened-package-files branch from 55d6126 to 452598b Compare May 7, 2025 18:15
@elliottt elliottt requested a review from jez May 7, 2025 18:47
}
e.setHeader("Package `{}` cannot {} itself", pkgInfo.name.toString(ctx), import_);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice

elliottt added 6 commits May 8, 2025 15:41
This delays destruction of the shared_ptr to the caller, but doesn't
modify the reference count.
We already guard __package.rb file changes from the fast path, but if
the file hasn't changed allow it to go through. However, we would also
filter __package.rb files out of the updated file set before running the
pipeline, which would lead to running the fast path on zero files.
Instead, let's build up the package files in a separate vector that we
extend with related package files, and merge right before the pipeline.
@elliottt elliottt force-pushed the trevor/cache-opened-package-files branch from 08cde54 to f470a22 Compare May 8, 2025 22:44
@elliottt elliottt merged commit caed2bb into master May 8, 2025
14 checks passed
@elliottt elliottt deleted the trevor/cache-opened-package-files branch May 8, 2025 23:50
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
0