-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
forc-pkg
: Refactor BuildPlan
construction and validation to minimize fetching, improve offline support, reduce I/O, fix bugs.
#2234
Conversation
…pendency removal from manifest file.
Co-authored-by: mitchmindtree <mitchell.nordine@fuel.sh>
This commit reduces the number of times that we need to read each dependency's manifest from file in order to reduce the amount of I/O performed. Each dependency's manifest should now only be loaded once during either `graph_to_manifest_map` or `fetch_graph`. This required implementing `Clone` for `ManifestFile` to allow for constructing the build plan in a manner that does not require consuming the manifest file. `ManifestFile::clone` should only ever be called for the root node. As a side-effect, the `build` and `check` commands no longer require loading each package's manifest as they are already provided by the build plan. As a result both commands no longer require the sway git tag to be passed through.
forc-pkg
: Refactor BuildPlan
construction and validation to minimize fetching, improve offline support, reduce I/O.forc-pkg
: Refactor BuildPlan
construction and validation to minimize fetching, improve offline support, reduce I/O, fix bugs.
Previously, all dependency nodes were removed in the case that they were invalid for any one of their parents. This commit changes the behaviour to not remove the node, but rather each invalid dependency *edge* instead. This means that if a node is valid for one parent but not another, only the edge to the other parent is removed and not the whole node itself. The node is only removed in the case that it is invalid for all of its parents. This is necessary for handling the case where a dependency no longer exists in one parent's `[dependencies]` but still exists in another. The most common case for this is `std`, as many nodes may depend on `std` however we don't want to remove `std` and have to re-fetch it just because one of the nodes removed their depenency on it.
6daaea1
to
02ceb92
Compare
This is checked during the `validate_graph` phase. Also improves a bunch of comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 🙌 , just left a small nit (which is not a blocker, just a simple typo).
Also a side note I realized the build process is considerably faster (while adding a new dep) with this PR. A small benchmark on my m1 MBA:
Adding dep (existing Forc.lock) before this PR: 3.18 seconds
Adding dep (existing Forc.lock) with this PR: 0.79 seconds
Co-authored-by: Kaya Gökalp <kayagokalp@sabanciuniv.edu>
Should this be merged into #1974 instead of |
I think it's fine to merge this into master and close #1974. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. Looks good.
Ah I should have clarified this in my OP a bit further! I decided to base directly against |
This continues @kayagokalp's great work on #1974 with a wider overhaul of the package graph
BuildPlan
validation and construction.BuildPlan
refactorDuring kaya's work on #1974 it became clear we needed to reconsider the approach to package graph validation in order to be able to more generally account for all of the different ways a node might have been invalidated since the lock file was last written, and to be able to handle invalidated nodes in a more consistent manner.
This refactors the build plan construction process into the following distinct steps:
Source
differs from the source or patch described in the parent's manifest.offline
, only fail if we are missing agit
node.Closes #1903.
Closes #1778.
Makes progress on #895, #1787.
PathMap
ManifestMap
This PR also reduces the number of times that we need to read each dependency's manifest from file in order to reduce the amount of I/O performed. Each dependency's manifest should now be loaded once during either
graph_to_manifest_map
orfetch_graph
.This required implementing
Clone
forManifestFile
to allow for constructing the build plan in a manner that does not require consuming the manifest file.ManifestFile::clone
is only ever called for the project manifest, and never for the dependencies.As a side-effect, the
build
andcheck
commands no longer require loading each package's manifest as they are already provided by the build plan. As a result both commands no longer require the sway git tag to be passed through.