-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cue/load: avoid repeatedly loading parent directories by caching
In order to load a cue package, the `cue.load.loader` performs various CPU/IO heavy operations: - readDir: in order to load a cue instance, all ancestors of the instance directory are loaded as well, causing multiple dir reads. In case multiple instances are loaded, such as in `cue fmt ./...`, the same directory may be read many times as we descend into subdirectories - each file is loaded as a `*build.File` and its source parsed as an `*ast.File` We now maintain two separate caches of the above work: - a cache of directory path to []*build.File - a cache of file path to []*ast.File After this change we can see the following speedup on my monorepo: before: cue fmt --check ./... 2.50s user 0.54s system 83% cpu 3.661 total after: cue fmt --check ./... 0.72s user 0.21s system 51% cpu 1.815 total Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com> Change-Id: I95472ad22eb124df730f6711af730425106a85e8 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193678 TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
- Loading branch information
Showing
3 changed files
with
90 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters