-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(watcher): use exclude options to optimize file watching
This basically relies on optimizations already implemented in chokidar, the library we use for file watching. Hopefully this can solve the excessive CPU/RAM usage some users have reported. Closes #1269
- Loading branch information
Showing
13 changed files
with
128 additions
and
61 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
**/project-excluded.txt | ||
**/gardenignore-excluded.txt |
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
1 change: 1 addition & 0 deletions
1
garden-service/test/data/test-project-watch/module-a/gardenignore-excluded.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Nope! |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dir* |
16 changes: 16 additions & 0 deletions
16
garden-service/test/data/test-projects/huge-project/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Huge project tests | ||
|
||
Created for [PR #1320](https://github.com/garden-io/garden/pull/1320). | ||
|
||
This one's a bit hard to automate, but we can use to make sure Garden can handle massive amounts of files in repositories. | ||
|
||
The procedure to test was as follows: | ||
|
||
1) `cd` to this directory. | ||
2) Run `node generate.js`. | ||
3) Comment out the `modules.exclude` field in the `garden.yml`. | ||
4) In `garden-service/src/watch.ts`, add `usePolling: true` to the options for the chokidar `watch()` function. | ||
5) Run `garden build -w` and observe the process drain CPU and RAM until it crashes in about a minute. | ||
6) Uncomment the `modules.exclude` field in the `garden.yml`. | ||
7) Run `garden build -w` again, wait and observe a happy process for a while. | ||
8) Run `rm -rf dir*` to clean up. |
5 changes: 5 additions & 0 deletions
5
garden-service/test/data/test-projects/huge-project/garden.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
kind: Project | ||
name: huge-project | ||
dotIgnoreFiles: [.gardenignore] | ||
modules: | ||
exclude: [dir0/**/*, dir1/**/*, dir2/**/*, dir3/**/*, dir4/**/*, dir5/**/*, dir6/**/*, dir7/**/*, dir8/**/*] |
42 changes: 42 additions & 0 deletions
42
garden-service/test/data/test-projects/huge-project/generate.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const { join } = require("path") | ||
const { ensureDir, ensureFile } = require("fs-extra") | ||
|
||
let levels = 6 | ||
let directoriesPerLevel = 6 | ||
let filesPerLevel = 3 | ||
|
||
async function generateData(cwd, level) { | ||
level++ | ||
|
||
let files = 0 | ||
let directories = 0 | ||
|
||
for (let d = 0; d < directoriesPerLevel; d++) { | ||
const dir = join(cwd, "dir" + d) | ||
await ensureDir(dir) | ||
directories++ | ||
|
||
for (let f = 0; f < filesPerLevel; f++) { | ||
const file = join(dir, "file" + f) | ||
await ensureFile(file) | ||
files++ | ||
} | ||
|
||
if (level < levels) { | ||
const res = await generateData(dir, level) | ||
files += res.files | ||
directories += res.directories | ||
} | ||
} | ||
|
||
return { files, directories } | ||
} | ||
|
||
generateData(process.cwd(), 0) | ||
.then((res) => { | ||
console.log(`Made ${res.files} files in ${res.directories} directories`) | ||
}) | ||
.catch(err => { | ||
console.log(err) | ||
process.exit(1) | ||
}) |
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