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
Fix: Improves perf of globbing by inheriting glob.GlobSync (fixes #6710) #6783
Fix: Improves perf of globbing by inheriting glob.GlobSync (fixes #6710) #6783
Conversation
LGTM |
@kaelzhang, thanks for your PR! By analyzing the annotation information on this pull request, we identified @alberto, @IanVS and @gronke to be potential reviewers |
Thank you for your pull request. It looks like this may be your first contribution to a jQuery Foundation project, if so we need you to sign our Contributor License Agreement (CLA). 📝 Please visit http://contribute.jquery.org/CLA/ to sign. After you signed, the PR is checked again automatically after a minute. If there's still an issue, please reply here to let us know. If you've already signed our CLA, it's possible your git author information doesn't match your CLA signature (both your name and email have to match), for more information, check the status of your CLA check. |
// Private | ||
//------------------------------------------------------------------------------ | ||
|
||
var IGNORE = typeof Symbol === "function" ? Symbol("ignore") : "_shouldIgnore"; |
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.
Node.js supports symbols since 0.12. ESLint requires >=Node 4
, so we can use symbols always.
This looks a lot better then previous attempt, @kaelzhang could you rebase please? @eslint/eslint-team Can you review this, since this is a pretty impactful change, I'd like to have as many eyes on this as we can? Especially @IanVS and @alberto since you've been dealing with this part of the code lately. |
* so that subtle directories could be re-included by .gitignore patterns | ||
* such as `"!node_modules/should_not_ignored"` | ||
*/ | ||
var dirs = DEFAULT_IGNORE_DIRS.map(function(dir) { |
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.
It looks like both times that DEFAULT_IGNORE_DIRS
is used we are adding the *
to the end, so how about just changing DEFAULT_IGNORE_DIRS
? Also, the other usage of DEFAULT_IGNORE_DIRS
adds a leading slash, so maybe the final result should be:
var DEFAULT_IGNORE_DIRS = [
"/node_modules/*",
"/bower_components/*"
];
I do like the note explaining why the *
is needed, though!
I tried to rebase and got bogged down, so I'm going to wait for @kaelzhang to rebase it. Then I would like to see how it would play together with https://github.com/eslint/eslint/pull/6844/files. I don't necessarily anticipate any problems, but it's all pretty related so it would be good to check. From what I can tell just looking over the code and the tests, this all looks good (with the caveat that I don't fully understand the changes to the glob functionality). |
@IanVS Sorry that I have been away for a while. I will work on this asap. |
146ad84
to
f2a8ea6
Compare
LGTM |
f2a8ea6
to
4d87017
Compare
LGTM |
* But doing this leads to a breaking change and fails tests. | ||
* Related to #6759 | ||
*/ | ||
const base = this.options.cwd; |
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.
In the near future, we need to change this.
Appveyor reached a timeout
|
4d87017
to
0a2449c
Compare
LGTM |
* so that subtle directories could be re-included by .gitignore patterns | ||
* such as `"!node_modules/should_not_ignored"` | ||
*/ | ||
const dirs = DEFAULT_IGNORE_DIRS.map(function(dir) { |
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.
It seems my previous comment #6783 (comment) was lost in the rebase. I still think it would be cleaner to just make the DEFAULT_IGNORE_DIRS
the way we want them.
@kaelzhang I rebased my #6844 on top of this branch and it all still works fine. The code of this PR looks great, but it looks like you need to sign the jQuery CLA before we could merge this. Also, do you have any performance data to show that speed is improved as a result of these changes? |
0a2449c
to
d8dec4a
Compare
LGTM |
d8dec4a
to
6e7b065
Compare
LGTM |
@IanVS Seems that I can't change my full name of jQuery CLA signature, so I had to change my name in git config 😢 I'll add some performance data later. |
6e7b065
to
bd286ad
Compare
LGTM |
bd286ad
to
3c472fd
Compare
LGTM |
Responding to your note from another issue: the code LGTM, but I'm not an official reviewer. Also, I think you were going to try to gather some performance data, is that still possible? I think it would be helpful. |
I tested on an npm package, dat which has 506 dependencies (including subtle dependencies). .eslintignore:
.eslintrc {
"root": true,
"extends": "eslint:recommended"
} And the script is: const spawn = require('cross-spawn').sync
const time1 = + new Date
// local eslint(pr #6783) created with npm link
spawn('eslint', ['.'], { stdio: 'inherit' })
const time2 = + new Date
// eslint 3.3.0
spawn('./node_modules/.bin/eslint', ['.'], { stdio: 'inherit' })
const time3 = + new Date
console.log(`
eslint npm package, dat:
- eslint #6783 : ${time2 - time1} ms
- eslint 3.3.0 : ${time3 - time2} ms
`) Output:
|
So, am I reading correctly that with this branch it took longer to lint? :-/ |
@IanVS I made a mistake with the last |
👍 |
LGTM, thanks @kaelzhang! |
LGTM. Thanks @kaelzhang for your work on this! |
What issue does this pull request address?
As #6710 discussed, I create a subclass of
glob.GlobSync
to skip certain glob process according to .gitignore rules.What changes did you make? (Give an overview)
glob.GlobSync
and overrides_readdir
, special thanks to the good idea of @mysticatea. But there are several detail things we should aware of, see the inline comments of the commit.ignoredPaths.getIgnoredFoldersGlobPatterns()
->ignoredPaths.getIgnoredFoldersGlobChecker()
, and now it will return a function.Is there anything you'd like reviewers to focus on?
Do I need to create a specific test cases file for
lib/glob.js
? Or just testing it withglob-util.js
is ok? I did create a test file, because I thought there was much duplication withtests/lib/glob-util.js
If it is necessary, I will add one.