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

When a file is changed, only mark targets that depend on it as out-of-date #1313

Merged

Conversation

ahoppen
Copy link
Collaborator

@ahoppen ahoppen commented May 16, 2024

No description provided.

@ahoppen
Copy link
Collaborator Author

ahoppen commented May 16, 2024

@swift-ci Please test

/// necessary by scheduling re-preparation of a target where it isn't necessary.
///
/// Returning `nil` indicates that all targets should be considered depending on the given target.
func targets(dependingOn targets: [ConfiguredTarget]) async -> [ConfiguredTarget]?
Copy link
Contributor

Choose a reason for hiding this comment

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

Would taking Target make more sense here? We don't really care about the possibly large set of configured targets as input. I'd argue that's even the case for output, but we do need the configured target eventually since that's what we track preparation of.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, Alex brought up a very valid point here. It's entirely possible that while the concept of a "target" may contain the file, the underlying target + platform may not - consider settings for including/excluding files per platform. So ConfiguredTarget really is the right abstraction here, thanks for remembering that one :).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added the following comment to SemanticIndexManager.filesDidChange

    // Note that configured targets are the right abstraction layer here (instead of a non-configured target) because a
    // build system might have targets that include different source files. Hence a source file might be in target T
    // configured for macOS but not in target T configured for iOS.

Comment on lines +218 to +222
// We couldn't determine which targets depend on the modified targets. Be conservative and assume all of them do.
preparationStatus = [:]
Copy link
Contributor

Choose a reason for hiding this comment

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

We could not remove targets in this case, not that it's really expected to happen anyway.

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 only case where we’d be able to not remove the target itself is if there is only a single target. Say you have a project two targets A and B and you change one file in A and one file in B then you don’t know if they depend on each other and you need to assume that they do. So you need to invalidate both.

I don’t think it’s worth optimizing for the single module case. Really, the build system should provide more accurate information here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Single target is the main case though 😅 I agree the buildsystem should, but asking for preparation on every edit is really pretty bad.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In one of my follow-up PRs (not up yet), I’m re-implementing the entire up-to-date tracking of targets and that allows us to early-exit if we know that the target is up-to-date without any build system interaction.

Copy link
Contributor

@hamishknight hamishknight left a comment

Choose a reason for hiding this comment

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

Same question as Ben regarding whether the dependencies should work with ConfiguredTargets, but otherwise LGTM

@ahoppen ahoppen force-pushed the only-mark-dependent-targets-as-out-of-date branch from 60d8a3e to a850cb6 Compare May 17, 2024 21:33
@ahoppen
Copy link
Collaborator Author

ahoppen commented May 17, 2024

@swift-ci Please test

@ahoppen
Copy link
Collaborator Author

ahoppen commented May 17, 2024

@swift-ci Please test Windows

2 similar comments
@ahoppen
Copy link
Collaborator Author

ahoppen commented May 17, 2024

@swift-ci Please test Windows

@ahoppen
Copy link
Collaborator Author

ahoppen commented May 20, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit af6cdeb into apple:main May 20, 2024
3 checks passed
@ahoppen ahoppen deleted the only-mark-dependent-targets-as-out-of-date branch May 20, 2024 20:40
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.

None yet

3 participants