Skip to content
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

Merged
merged 1 commit into from Aug 22, 2016

Conversation

kaelzhang
Copy link

@kaelzhang kaelzhang commented Jul 28, 2016

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)

  • inherits 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.
  • change 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 with glob-util.js is ok? I did create a test file, because I thought there was much duplication with tests/lib/glob-util.js

If it is necessary, I will add one.

@eslintbot
Copy link

LGTM

@mention-bot
Copy link

@kaelzhang, thanks for your PR! By analyzing the annotation information on this pull request, we identified @alberto, @IanVS and @gronke to be potential reviewers

@jquerybot
Copy link

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";
Copy link
Member

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.

http://node.green/#Symbol

@ilyavolodin
Copy link
Member

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) {
Copy link
Member

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!

@IanVS
Copy link
Member

IanVS commented Aug 9, 2016

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).

@kaelzhang
Copy link
Author

@IanVS Sorry that I have been away for a while. I will work on this asap.

@eslintbot
Copy link

LGTM

@kaelzhang
Copy link
Author

kaelzhang commented Aug 9, 2016

@IanVS This pr will not solve #6759 which I think should be fixed separately from the current issue.

@eslintbot
Copy link

LGTM

* But doing this leads to a breaking change and fails tests.
* Related to #6759
*/
const base = this.options.cwd;
Copy link
Author

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.

@kaelzhang
Copy link
Author

kaelzhang commented Aug 9, 2016

@IanVS I've made some changes related to #6759 so that there won't be too much changes the day we want to fix that issue.

I also marked a few lines that should be altered later.

@kaelzhang
Copy link
Author

Appveyor reached a timeout

Build execution time has reached the maximum allowed time for your plan (60 minutes).

@eslintbot
Copy link

LGTM

@IanVS IanVS changed the title Fix: Improves pref of globbing by inheriting glob.GlobSync (fixes #6710) Fix: Improves perf of globbing by inheriting glob.GlobSync (fixes #6710) Aug 13, 2016
* 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) {
Copy link
Member

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.

@IanVS
Copy link
Member

IanVS commented Aug 13, 2016

@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?

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@kaelzhang
Copy link
Author

@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.

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@IanVS
Copy link
Member

IanVS commented Aug 19, 2016

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.

@kaelzhang
Copy link
Author

kaelzhang commented Aug 20, 2016

I tested on an npm package, dat which has 506 dependencies (including subtle dependencies).

.eslintignore:

!node_modules/acorn

.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:

eslint npm package, dat:

- eslint #6783 : 1861 ms
- eslint 3.3.0 : 2709 ms

@IanVS
Copy link
Member

IanVS commented Aug 20, 2016

So, am I reading correctly that with this branch it took longer to lint? :-/

@kaelzhang
Copy link
Author

@IanVS I made a mistake with the last console.log(). This branch lints much faster, and the result is not excluded with the lint part (CLI-Engine -> Lint)

@mysticatea
Copy link
Member

👍

@alberto
Copy link
Member

alberto commented Aug 21, 2016

LGTM, thanks @kaelzhang!

@ilyavolodin
Copy link
Member

LGTM. Thanks @kaelzhang for your work on this!

@ilyavolodin ilyavolodin merged commit 8851ddd into eslint:master Aug 22, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants