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

[move-ide] Avoid analyzing unmodified dependencies #20046

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

awelc
Copy link
Contributor

@awelc awelc commented Oct 27, 2024

Description

This PR implements an optimization to the symbolication algorithm that avoids analyzing dependencies if they have not changed. Previously we were avoiding re-compiling unchanged dependencies but we were still analyzing them which introduces unnecessary overhead.

The implementation involved separating analysis of the main program and the dependencies, and merging the results of the two together in the end (whether the dependencies are computed fresh or obtained from the cache). In particular, we now create two analysis visitors per analysis phase, one for the main program and one for the dependencies.

For a simple package with Sui framework as a dependency we observe a significant reduction in analysis time.

Before:
image

After:
image

Test plan

All existing test must pass. I also tested manually to verify that reporting references (now merged between the main program and the dependencies) works correctly.

@awelc awelc self-assigned this Oct 27, 2024
Copy link

vercel bot commented Oct 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 27, 2024 0:22am
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Oct 27, 2024 0:22am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Oct 27, 2024 0:22am
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Oct 27, 2024 0:22am

/// Package path
path: PathBuf,
/// Manifest hash
manifest_hash: Option<FileHash>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the manifest file the "right" thing to do here? It is possible a downstream dependency lives locally and got changed, and it appears this would not pick that change up. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, if the local dependency changes (whether direct or indirect), the IDE will not know about it. The idea here is that indeed if dependencies are changed "in the background" during a single editing session, things may indeed go out of sync, in which case re-starting the IDE will fix it (as everything will be re-fetched from disk).

In addition to what you observed, we also do not actually re-fetch (direct) remote dependencies if they change in the remote repo (GitHub). This is because the check for remote change had to happen at each compilation and was slowing down compilation/analysis enough that things like auto-completion was being too slow. Since we already do not track that, it seemed like only tracking explicit dependency changes (via manifest file changes) makes sense, as there is already a way when dependencies can change during a single editing session.

Copy link
Contributor

@cgswords cgswords left a comment

Choose a reason for hiding this comment

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

LGTM other than manifest file question, which we should resolve before landing this. Stamping approved, but let us settle that.

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