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

High CPU usage while idle #415

Closed
kant2002 opened this issue Sep 4, 2015 · 18 comments
Closed

High CPU usage while idle #415

kant2002 opened this issue Sep 4, 2015 · 18 comments
Assignees

Comments

@kant2002
Copy link
Contributor

kant2002 commented Sep 4, 2015

I open my project, working on it for some time, then during seeking and finding stuff which I need the VS start freezing and eat ~30% CPU. All CPU distributed evenly across the processors.
It taking ~20 minutes so far and I kill process.

I take two dump to take a look at what happens. Both show on the same place - Quick Intellisense source. Take a look. I was on RC1.1 Release version + VS2015.

OS Thread Id: 0x1d1c (0)
Current frame: (MethodDesc 063ed3e8 +0xa7 Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.AddOne(Bucket[], Microsoft.NodejsTools.Analysis.AnalysisProxy, Int32))
ChildEBP RetAddr  Caller, Callee
0052e4c4 0052e4e4 0052e4e4, calling 4c582088
0052e4c8 15cec5a9 (MethodDesc 063ed3dc +0x29 Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.Add(Bucket[], Microsoft.NodejsTools.Analysis.AnalysisProxy)), calling (MethodDesc 063ed3e8 +0 Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.AddOne(Bucket[], Microsoft.NodejsTools.Analysis.AnalysisProxy, Int32))
0052e4e4 15cec524 (MethodDesc 063ed3ac +0x3c Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.AddOne(Microsoft.NodejsTools.Analysis.AnalysisProxy)), calling (MethodDesc 063ed3dc +0 Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.Add(Bucket[], Microsoft.NodejsTools.Analysis.AnalysisProxy))
0052e4f8 17a097ef (MethodDesc 063ed39c +0x7f Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.Union(System.Collections.Generic.IEnumerable`1<Microsoft.NodejsTools.Analysis.AnalysisProxy>, Boolean ByRef)), calling (MethodDesc 063ed3ac +0 Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.AddOne(Microsoft.NodejsTools.Analysis.AnalysisProxy))
0052e530 17a06a24 (MethodDesc 063ee678 +0x204 Microsoft.NodejsTools.Analysis.TypedDef`1[[System.__Canon, mscorlib]].GetTypesWorker(Microsoft.NodejsTools.Analysis.ProjectEntry, Microsoft.NodejsTools.Analysis.ProjectEntry, Boolean ByRef)), calling 1458e66a
0052e584 17a0774f (MethodDesc 063e8e1c +0x57 Microsoft.NodejsTools.Analysis.Values.ObjectValue.GetPrototype(Microsoft.NodejsTools.Analysis.ProjectEntry)), calling (MethodDesc 063ee678 +0 Microsoft.NodejsTools.Analysis.TypedDef`1[[System.__Canon, mscorlib]].GetTypesWorker(Microsoft.NodejsTools.Analysis.ProjectEntry, Microsoft.NodejsTools.Analysis.ProjectEntry, Boolean ByRef))
0052e5a4 17a074fe (MethodDesc 063e8e10 +0x4e Microsoft.NodejsTools.Analysis.Values.ObjectValue.GetRecurse(Microsoft.NodejsTools.Analysis.AnalysisValue, Microsoft.NodejsTools.Parsing.Node, Microsoft.NodejsTools.Analysis.AnalysisUnit, System.String, Boolean))
..... stripped same methods ....
0052ed1c 0052ed7c 0052ed7c, calling 3a7b35a8
0052ed20 17a075c3 (MethodDesc 063e8e10 +0x113 Microsoft.NodejsTools.Analysis.Values.ObjectValue.GetRecurse(Microsoft.NodejsTools.Analysis.AnalysisValue, Microsoft.NodejsTools.Parsing.Node, Microsoft.NodejsTools.Analysis.AnalysisUnit, System.String, Boolean)), calling (MethodDesc 063e8e10 +0 Microsoft.NodejsTools.Analysis.Values.ObjectValue.GetRecurse(Microsoft.NodejsTools.Analysis.AnalysisValue, Microsoft.NodejsTools.Parsing.Node, Microsoft.NodejsTools.Analysis.AnalysisUnit, System.String, Boolean))
0052ed7c 17a063c8 (MethodDesc 063e8df0 +0x50 Microsoft.NodejsTools.Analysis.Values.ObjectValue.Get(Microsoft.NodejsTools.Parsing.Node, Microsoft.NodejsTools.Analysis.AnalysisUnit, System.String, Boolean)), calling (MethodDesc 063e8e10 +0 Microsoft.NodejsTools.Analysis.Values.ObjectValue.GetRecurse(Microsoft.NodejsTools.Analysis.AnalysisValue, Microsoft.NodejsTools.Parsing.Node, Microsoft.NodejsTools.Analysis.AnalysisUnit, System.String, Boolean))
0052eda8 17a09d3e (MethodDesc 05f63d2c +0x6e Microsoft.NodejsTools.Analysis.AnalysisSetExtensions.Get(Microsoft.NodejsTools.Analysis.IAnalysisSet, Microsoft.NodejsTools.Parsing.Node, Microsoft.NodejsTools.Analysis.AnalysisUnit, System.String, Boolean))
0052ede8 17a09cbb (MethodDesc 05f62d60 +0x4b Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.EvaluateMember(Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator, Microsoft.NodejsTools.Parsing.Node)), calling (MethodDesc 05f63d2c +0 Microsoft.NodejsTools.Analysis.AnalysisSetExtensions.Get(Microsoft.NodejsTools.Analysis.IAnalysisSet, Microsoft.NodejsTools.Parsing.Node, Microsoft.NodejsTools.Analysis.AnalysisUnit, System.String, Boolean))
0052ee08 17a0540f (MethodDesc 05f62d24 +0x4f Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.EvaluateWorker(Microsoft.NodejsTools.Parsing.Node))
0052ee20 17a09ca8 (MethodDesc 05f62d60 +0x38 Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.EvaluateMember(Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator, Microsoft.NodejsTools.Parsing.Node)), calling (MethodDesc 05f62d24 +0 Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.EvaluateWorker(Microsoft.NodejsTools.Parsing.Node))
0052ee34 17a0540f (MethodDesc 05f62d24 +0x4f Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.EvaluateWorker(Microsoft.NodejsTools.Parsing.Node))
0052ee4c 17a05ef2 (MethodDesc 05f62dd8 +0x42 Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.Evaluate(Microsoft.NodejsTools.Parsing.Expression[])), calling (MethodDesc 05f62d24 +0 Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.EvaluateWorker(Microsoft.NodejsTools.Parsing.Node))
0052ee6c 17a05d50 (MethodDesc 05f62db4 +0x68 Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.EvaluateCall(Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator, Microsoft.NodejsTools.Parsing.Node)), calling (MethodDesc 05f62dd8 +0 Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.Evaluate(Microsoft.NodejsTools.Parsing.Expression[]))
0052ee98 713b8340 (MethodDesc 7112237c +0x30 System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].TryGetValue(System.__Canon, System.__Canon ByRef)), calling *** ERROR: Symbol file could not be found.  Defaulted to export symbols for clr.dll - 
clr+0x18e8
0052eea8 0052eec4 0052eec4, calling 3a7de4a0
0052eeac 17a0540f (MethodDesc 05f62d24 +0x4f Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.EvaluateWorker(Microsoft.NodejsTools.Parsing.Node))
0052eec4 064f8e02 (MethodDesc 15c130fc +0x82 Microsoft.NodejsTools.Analysis.ModuleAnalysis.GetValuesByIndex(System.String, Int32)), calling (MethodDesc 05f62d24 +0 Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.EvaluateWorker(Microsoft.NodejsTools.Parsing.Node))
0052eef8 0052ef34 0052ef34, calling 00a5debc
0052eefc 064f8c73 (MethodDesc 565639b0 +0x63 Microsoft.NodejsTools.Intellisense.ExpressionAnalysis.get_Values()), calling (MethodDesc 15c130fc +0 Microsoft.NodejsTools.Analysis.ModuleAnalysis.GetValuesByIndex(System.String, Int32))
0052ef34 064f89d6 (MethodDesc 565638a4 +0x96 Microsoft.NodejsTools.Intellisense.QuickInfoSource.AugmentQuickInfoWorker(Microsoft.NodejsTools.Intellisense.ExpressionAnalysis, System.Collections.Generic.IList`1<System.Object>, Microsoft.VisualStudio.Text.ITrackingSpan ByRef)), calling (MethodDesc 565639b0 +0 Microsoft.NodejsTools.Intellisense.ExpressionAnalysis.get_Values())
0052ef84 064f719c (MethodDesc 5656388c +0x2c Microsoft.NodejsTools.Intellisense.QuickInfoSource.AnalyzeExpression(Microsoft.VisualStudio.Language.Intellisense.IQuickInfoSession)), calling (MethodDesc 062c4240 +0 Microsoft.NodejsTools.Intellisense.VsProjectAnalyzer.AnalyzeExpression(Microsoft.VisualStudio.Text.ITextSnapshot, Microsoft.VisualStudio.Text.ITrackingSpan, Boolean))
0052ef98 064f7152 (MethodDesc 56563884 +0x72 Microsoft.NodejsTools.Intellisense.QuickInfoSource.AugmentQuickInfoSession(Microsoft.VisualStudio.Language.Intellisense.IQuickInfoSession, System.Collections.Generic.IList`1<System.Object>, Microsoft.VisualStudio.Text.ITrackingSpan ByRef)), calling (MethodDesc 565638a4 +0 Microsoft.NodejsTools.Intellisense.QuickInfoSource.AugmentQuickInfoWorker(Microsoft.NodejsTools.Intellisense.ExpressionAnalysis, System.Collections.Generic.IList`1<System.Object>, Microsoft.VisualStudio.Text.ITrackingSpan ByRef))
0052efac 0052f034 0052f034, calling c883f98c
0052efb0 2fba3590 (MethodDesc 57ea1c80 +0xf8 Microsoft.VisualStudio.Language.Intellisense.Implementation.QuickInfoSession.Recalculate()), calling 1795b3ca
0052efbc 58010284 (MethodDesc 57ebaf38 +0xc4 Microsoft.VisualStudio.Language.Intellisense.Implementation.IntellisenseSessionStack.DoleOutKeyboard()), calling 12dbc0a6
0052f034 2fba33c4 (MethodDesc 57ea1c40 +0x1c Microsoft.VisualStudio.Language.Intellisense.Implementation.QuickInfoSession.Start())
0052f040 2fba3093 (MethodDesc 57eca0a0 +0x1b Microsoft.VisualStudio.Language.Intellisense.Implementation.QuickInfoBroker.TriggerQuickInfo(Microsoft.VisualStudio.Text.Editor.ITextView, Microsoft.VisualStudio.Text.ITrackingPoint, Boolean)), calling 50fe6426
0052f048 0052f078 0052f078, calling 00a5e120
0052f04c 064f7034 (MethodDesc 17c07980 +0xbc Microsoft.NodejsTools.Intellisense.IntellisenseController.TextViewMouseHover(System.Object, Microsoft.VisualStudio.Text.Editor.MouseHoverEventArgs)), calling 12dccf56
0052f078 2fba2ead (MethodDesc 57eb21e8 +0x215 Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.RaiseHoverEvents())
@nippur72
Copy link

nippur72 commented Sep 4, 2015

Same here, CPU at ~30%, lagging intellisense, slow to load and unload the project.

It has been a while since I have this problem, I thought it was due to #384, but it's not since the issue was closed and I use now the 1.1 RC2.

Don't know if it's related, but I start to get problems once I add the npm package mssql.

@billti
Copy link
Member

billti commented Sep 5, 2015

Trying to get to the bottom of this now. I seem to have a repro. Though it doesn't match the call stacks above, it does fully consume a thread on a quad core, meaning about 25% constant CPU.

In my repro it looks like its updating the NPM catalog that's the issue. It seems the offending line of code is in the below code (see my comment annotation):

NpmGetCatalogCommands.cs@100

while (module != null) {
    try {
        builder.Name = (string)module["name"];
        if (string.IsNullOrEmpty(builder.Name)) {
            continue;  /**** just repeats the while loop with no change in state ****/
        }

It appears the data coming from NPM from the catalog isn't as expected, so trying to root cause this now...

@billti billti self-assigned this Sep 5, 2015
@billti billti added this to the September milestone Sep 5, 2015
@kant2002
Copy link
Contributor Author

kant2002 commented Sep 5, 2015

I have issue with npm catalog with duplicate properties in package.json. so that's could be the cause of wrong data

@billti
Copy link
Member

billti commented Sep 5, 2015

The logic for the JSON schema parsing was a little off. For example, if you go to https://registry.npmjs.org/-/all/static/today.json you can see it just returns an array of package objects. The current code was parsing incorrectly and getting in an infinite loop (as outlined above).

I've started a branch to fix this. Currently is has one commit to handle the schema properly (7900e27). It still needs to be updated for where it was expecting to find an _updated property, as I don't see that in the responses now. If I look at how NPM handles this ( https://github.com/npm/npm/blob/master/lib/cache/update-index.js#L88 ), it seems it will just use the HTTP Date header if not present in the JSON, so we probably need to do the same.

Going to bed now. Will finish this up over the coming days (and try any other repros for the high CPU).

@kant2002
Copy link
Contributor Author

kant2002 commented Sep 8, 2015

@billti I would suggest thing about other JSON library, or take another approach. The reason for that is #106 which seems trivial to implement, but with current approach this is not possible. NTVS need more flexible JSON parser. Same with #208, too strict parser is good when developing application, but since you could not restrict NPM and your users NTVS should be more tolerable to issues in the external deps.

I look at the Newtonsonft.JSON API and does not find a way how I could implement loose JSON. If you have an idea, I could try work on these kind of issues.

Also, do you have any news on this issue?

@billti
Copy link
Member

billti commented Sep 8, 2015

The JSON parse in this case is fine and doing exactly what is expected. It is the NTVS code which is wrong, and looping without advancing the parser - hence the infinite loop and CPU usage.

When you say "Do you have any news on this issue?", you mean since 3 days ago when I last updated this? Then no. It's been a long weekend here and I managed to keep my laptop closed for most of it :-)

@kant2002
Copy link
Contributor Author

kant2002 commented Sep 8, 2015

You are right, it's only 3 days. I have to work less, to not push people who don't work on weekends. My apologize for being too pushy 😄

@billti
Copy link
Member

billti commented Sep 9, 2015

Per @nippur72 above, I added the mssql module in a project while investigating other issues, and started seeing the high CPU usage again, but this time with the analysis engine.

Looking at the call stacks when broken, I see similar to the below quite consistently:

    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.AddOne(Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.Bucket[] buckets, Microsoft.NodejsTools.Analysis.AnalysisProxy key, int hc)   Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.Add(Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.Bucket[] buckets, Microsoft.NodejsTools.Analysis.AnalysisProxy key)  Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.AddOne(Microsoft.NodejsTools.Analysis.AnalysisProxy key)   Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.AnalysisSetDetails.AnalysisHashSet.Union(System.Collections.Generic.IEnumerable<Microsoft.NodejsTools.Analysis.AnalysisProxy> items, out bool wasChanged) Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.AnalysisSetExtensions.Call(Microsoft.NodejsTools.Analysis.IAnalysisSet self, Microsoft.NodejsTools.Parsing.Node node, Microsoft.NodejsTools.Analysis.AnalysisUnit unit, Microsoft.NodejsTools.Analysis.IAnalysisSet this, Microsoft.NodejsTools.Analysis.IAnalysisSet[] args) Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Values.PropertyDescriptorValue.GetValue(Microsoft.NodejsTools.Parsing.Node node, Microsoft.NodejsTools.Analysis.AnalysisUnit unit, Microsoft.NodejsTools.Analysis.ProjectEntry declaringScope, Microsoft.NodejsTools.Analysis.IAnalysisSet this, bool addRef) Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Values.ExpandoValue.Get(Microsoft.NodejsTools.Parsing.Node node, Microsoft.NodejsTools.Analysis.AnalysisUnit unit, string name, bool addRef)  Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Values.ObjectValue.Get(Microsoft.NodejsTools.Parsing.Node node, Microsoft.NodejsTools.Analysis.AnalysisUnit unit, string name, bool addRef)   Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Values.ExpandoValue.AddProperty(Microsoft.NodejsTools.Parsing.Node node, Microsoft.NodejsTools.Analysis.AnalysisUnit unit, string name, Microsoft.NodejsTools.Analysis.AnalysisValue value)   Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.GlobalBuilder.DefineProperty(Microsoft.NodejsTools.Analysis.Values.FunctionValue func, Microsoft.NodejsTools.Parsing.Node node, Microsoft.NodejsTools.Analysis.AnalysisUnit unit, Microsoft.NodejsTools.Analysis.IAnalysisSet this, Microsoft.NodejsTools.Analysis.IAnalysisSet[] args)   Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Values.SpecializedFunctionValue.Call(Microsoft.NodejsTools.Parsing.Node node, Microsoft.NodejsTools.Analysis.AnalysisUnit unit, Microsoft.NodejsTools.Analysis.IAnalysisSet this, Microsoft.NodejsTools.Analysis.IAnalysisSet[] args) Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.AnalysisSetExtensions.Call(Microsoft.NodejsTools.Analysis.IAnalysisSet self, Microsoft.NodejsTools.Parsing.Node node, Microsoft.NodejsTools.Analysis.AnalysisUnit unit, Microsoft.NodejsTools.Analysis.IAnalysisSet this, Microsoft.NodejsTools.Analysis.IAnalysisSet[] args) Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.EvaluateCall(Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator ee, Microsoft.NodejsTools.Parsing.Node node)    Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Analyzer.ExpressionEvaluator.EvaluateWorker(Microsoft.NodejsTools.Parsing.Node node)  Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Analyzer.DDG.Walk(Microsoft.NodejsTools.Parsing.ReturnNode node)  Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Parsing.ReturnNode.Walk(Microsoft.NodejsTools.Parsing.AstVisitor visitor)  Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Analyzer.DDG.Walk(Microsoft.NodejsTools.Parsing.Block node)   Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Parsing.Block.Walk(Microsoft.NodejsTools.Parsing.AstVisitor walker)    Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Analyzer.DDG.Walk(Microsoft.NodejsTools.Parsing.TryNode node) Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Parsing.TryNode.Walk(Microsoft.NodejsTools.Parsing.AstVisitor visitor) Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Analyzer.DDG.Walk(Microsoft.NodejsTools.Parsing.Block node)   Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Parsing.Block.Walk(Microsoft.NodejsTools.Parsing.AstVisitor walker)    Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Analyzer.DDG.Walk(Microsoft.NodejsTools.Parsing.IfNode node)  Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Parsing.IfNode.Walk(Microsoft.NodejsTools.Parsing.AstVisitor visitor)  Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Analyzer.DDG.Walk(Microsoft.NodejsTools.Parsing.Block node)   Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Parsing.Block.Walk(Microsoft.NodejsTools.Parsing.AstVisitor walker)    Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Analyzer.FunctionAnalysisUnit.AnalyzeWorker(Microsoft.NodejsTools.Analysis.Analyzer.DDG ddg, System.Threading.CancellationToken cancel)   Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.Analyzer.DDG.Analyze(Microsoft.NodejsTools.Analysis.Deque<Microsoft.NodejsTools.Analysis.AnalysisUnit> queue, System.Threading.CancellationToken cancel)  Unknown
    Microsoft.NodejsTools.Analysis.dll!Microsoft.NodejsTools.Analysis.JsAnalyzer.AnalyzeQueuedEntries(System.Threading.CancellationToken cancel)    Unknown
>   Microsoft.NodejsTools.dll!Microsoft.NodejsTools.Intellisense.VsProjectAnalyzer.AnalysisQueue.GroupAnalysis.Analyze(System.Threading.CancellationToken cancel) Line 247  C#
    Microsoft.NodejsTools.dll!Microsoft.NodejsTools.Intellisense.VsProjectAnalyzer.AnalysisQueue.Worker(object threadStarted) Line 183  C#

Looking at the diagnostics output and what it is analyzing at this point, I see the below:

[E] c:\temp\nodecons1\node_modules\mssql\node_modules\tedious\node_modules\babel-runtime\node_modules\core-js\library\modules\$.is-array-iter.js, 1679
[E] c:\temp\nodecons1\node_modules\mssql\node_modules\tedious\node_modules\babel-runtime\node_modules\core-js\library\modules\$.collection-strong.js, 1680
[D] c:\temp\nodecons1\node_modules\mssql\node_modules\tedious\node_modules\babel-runtime\node_modules\core-js\library\modules\es5.js, 1679
[D] c:\temp\nodecons1\node_modules\mssql\node_modules\tedious\node_modules\babel-runtime\node_modules\core-js\library\modules\es5.js, 1678
[D] c:\temp\nodecons1\node_modules\mssql\node_modules\tedious\node_modules\babel-runtime\node_modules\core-js\library\modules\es5.js, 1677
[D] c:\temp\nodecons1\node_modules\mssql\node_modules\tedious\node_modules\babel-runtime\node_modules\core-js\library\modules\es5.js, 1676
[D] c:\temp\nodecons1\node_modules\mssql\node_modules\tedious\node_modules\babel-runtime\node_modules\core-js\library\modules\es5.js, 1675
[D] c:\temp\nodecons1\node_modules\mssql\node_modules\tedious\node_modules\babel-runtime\node_modules\core-js\library\modules\es5.js, 1674
[D] c:\temp\nodecons1\node_modules\mssql\node_modules\tedious\node_modules\babel-runtime\node_modules\core-js\library\modules\$.to-object.js, 1673
[E] c:\temp\nodecons1\node_modules\mssql\node_modules\tedious\node_modules\babel-runtime\node_modules\core-js\library\modules\es6.array.fill.js, 1674
[D] c:\temp\nodecons1\node_modules\mssql\node_modules\tedious\node_modules\babel-runtime\node_modules\core-js\library\modules\$.to-object.js, 1673

Per the code at https://github.com/Microsoft/nodejstools/blob/master/Nodejs/Product/Nodejs/Microsoft.NodejsTools.targets#L12 , we should be ignoring core-js, as we know it has issues. Bug #316 is tracking this setting being ignored.

As core-js is being included by Babel, and as Babel is one of the most popular libraries out there, we should treat getting this fixed as a top priority.

mousetraps added a commit to mousetraps/nodejstools that referenced this issue Sep 10, 2015
microsoft#415 High CPU usage when using core-js
- we were not properly initializing _analysisIgnoredDirectories in certain
  scenarios. This was also preventing us from ignoring core-js by default,
  which was causing perf issues with some popular packages.
@mousetraps mousetraps assigned mousetraps and unassigned billti Sep 10, 2015
@mousetraps
Copy link
Contributor

@kant2002 regarding your first comment about CPU usage, what's the output in NTVS diagnostic info look like? (Tools > Node.js Tools > Diagnostic Info) that'll give us an idea of which packages are failing to complete analysis.

mousetraps added a commit to mousetraps/nodejstools that referenced this issue Sep 10, 2015
microsoft#415 High CPU usage when using core-js and bower_components
- we were not properly initializing _analysisIgnoredDirectories in certain
  scenarios. This was also preventing us from ignoring certain directories
  by default, which was causing perf issues with some popular packages.
mousetraps added a commit to mousetraps/nodejstools that referenced this issue Sep 10, 2015
microsoft#415 High CPU usage when using core-js and bower_components
- we were not properly initializing _analysisIgnoredDirectories in certain
  scenarios. This was also preventing us from ignoring certain directories
  by default, which was causing perf issues with some popular packages.
@kant2002
Copy link
Contributor Author

@mousetraps, I managed to remove NpmCache folder and update catalog and issues was gone. I also suspect that this is fix which already implemeted by Bill. If this issue happens to me I report again with diagnostics.

@mousetraps
Copy link
Contributor

@kant2002 Sounds good! The original callstack was in the analysis code, not the npm cache, so I'm skeptical it's the same issue.

@DrYSG
Copy link

DrYSG commented Sep 10, 2015

@kant2002

for us npm newbies, can you tell me how you remove the cache, and then update the catalog?

@kant2002
Copy link
Contributor Author

Please don't confuse NPM cache, with cache of NPM packages for NTVS.
NPM cache contains modules downloaded by NPM and located in the %appdata%\npm-cache.
cache of NPM packages for NTVS store list of all packages which listed in the NPM, and stored here %appdata%\..\local\microsoft\Node.js Tools\NpmCache. I clear the latter (%appdata%\..\local\microsoft\Node.js Tools\NpmCache), to prevent issue from appearing.

@kant2002
Copy link
Contributor Author

@DrYSG To answer your second question, I just open VS install package dialog and NTVS do that for me automatically.

@DrYSG
Copy link

DrYSG commented Sep 10, 2015

Thanks @kant2002, I did suspect I was confusing the two, which is why I wrote rather than just do something stupid first.

Here is what I did, Just to be safe I renamed (rather than deleted the .sqlite file and the all-packages.json file. When NodeTools downloaded it deleted everything and rebuilt the folder, and the sqlite file. It all works.

mousetraps added a commit that referenced this issue Sep 10, 2015
#316, #415 - AnalysisIgnoredDirectories not working and high cpu usage when using core-js and bower_components

We were not properly initializing _analysisIgnoredDirectories on project load. This was also preventing us from ignoring core-js and bower_components by default, which was causing perf issues with some popular packages.

Fixes #316, related to #415
@billti
Copy link
Member

billti commented Sep 11, 2015

@nippur72 @kant2002 We just pushed a new release with some fixes that could resolve this. See https://github.com/Microsoft/nodejstools/releases if you'd like to check it out. Thanks!

@billti
Copy link
Member

billti commented Sep 11, 2015

As mssql was identified as a cause above, and as we reproduced and fixed the issue this caused, closing this issue for now. Please reopen if this continues to be a problem with the latest RC2.1. Thanks!

@billti billti closed this as completed Sep 11, 2015
@nippur72
Copy link

@billti good work, I've just tried it and now the slowness is completely gone. Thank you, I've been waiting this for long!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants