Skip to content

refactor(@angular-devkit/schematics): improve performance of move()#12857

Merged
vikerman merged 1 commit into
angular:masterfrom
FrozenPandaz:improvemove
Nov 7, 2018
Merged

refactor(@angular-devkit/schematics): improve performance of move()#12857
vikerman merged 1 commit into
angular:masterfrom
FrozenPandaz:improvemove

Conversation

@FrozenPandaz
Copy link
Copy Markdown
Contributor

@FrozenPandaz FrozenPandaz commented Nov 2, 2018

Current Behavior

move goes through every single file in the workspace which includes node_modules which could possible be nested via tools like Lerna. Also for very large workspaces the same issues exist for source code.

Expected Behavior

Credits to @JamesHenry:

move should operate on just the sub tree so it will be fast even for huge workspaces.

Notes

DirEntry.visit was never ending if the visitor function renamed a file to a dir within itself (which the new implementation of move does), since it would mutate the DirEntry with a new file which it would then visit… and cause a never ending loop..

The old move mitigated this by using Tree.visit which collects all the files within the root DirEntry recursively and then proceeding with the calling the visitor function after all files were collected. I implemented a similar solution on HostDirEntry.visit and VirtualDirEntry.visit via adding a getSubfilesRecursively() method which I kept private for now so this could be released as a patch.

cc @hansl @alexeagle

@FrozenPandaz FrozenPandaz force-pushed the improvemove branch 2 times, most recently from 0ea3c44 to aa7eb81 Compare November 2, 2018 21:30
@FrozenPandaz FrozenPandaz changed the title enhancement: improve performance of move() refactor(@angular-devkit/schematics): improve performance of move() Nov 2, 2018
@FrozenPandaz FrozenPandaz force-pushed the improvemove branch 3 times, most recently from efafdb0 to a85c6ee Compare November 5, 2018 04:14
@vikerman
Copy link
Copy Markdown
Contributor

vikerman commented Nov 7, 2018

@hansl - Please add merge target

@hansl hansl added the target: patch This PR is targeted for the next patch release label Nov 7, 2018
@JamesHenry
Copy link
Copy Markdown
Contributor

🙌

@clydin
Copy link
Copy Markdown
Member

clydin commented Nov 7, 2018

Just a comment that mutating within a visitor is probably not something that should be encouraged and probably should break. I know it is already there but walking the entire tree before actually visiting has performance implications in light of the ability to short circuit as well as logic issues depending on the mutation of the original tree.

We should also consider deprecating exists as it is ambiguous regarding directories (fileExists/directoryExists?).

@vikerman vikerman merged commit 13c057a into angular:master Nov 7, 2018
@FrozenPandaz FrozenPandaz deleted the improvemove branch November 19, 2018 15:48
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants