Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 225707 - Resolving types in model is very slow
Resolving types in model is very slow
Product: javascript
Classification: Unclassified
Component: Editor
PC Linux
: P1 (vote)
: 7.3
Assigned To: Petr Pisl
Depends on:
  Show dependency treegraph
Reported: 2013-02-04 14:02 UTC by Petr Pisl
Modified: 2013-02-14 13:01 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT


Note You need to log in before you can comment on or make changes to this bug.
Description Petr Pisl 2013-02-04 14:02:08 UTC
The creating model from source has two main phases: Parsing and building model. Parsing is done in Nashorn and we can not influence it much. The building model has two parsts: creating objects from AST and resolving types of assignments, return types etc.

I have noticed that the resolving types is very slow for big files. For example for the file ext-4.0.7-gpl/examples/portal/classes.js (from Ext Js library) it takes whole parsing cycle more then about 9 seconds. Parsing in Nashor - 1 200 ms, creating objects from AST - 1 127ms and resolving types 5 890 ms.

So the part of resolving types is the most slow.
Comment 1 Petr Pisl 2013-02-04 14:08:59 UTC
The root of the problem is in the recursion that is used in ModelUtils.getDeclarationScope(Declaration scope, int offset). 

When the recursion I have replaced with new cycle the result time is about 3 second smaller. Parsing in Nashorn - 1200ms, creating object from AST - 630 ms and resolving types 1 400ms. This means that new algorithm is faster about 61%.
Comment 2 Petr Pisl 2013-02-04 14:13:16 UTC
The fix was pushed into the web-main:
Comment 3 Petr Pisl 2013-02-04 14:14:09 UTC
I would like to ask Petr Hejl to review it. Thanks
Comment 4 Petr Hejl 2013-02-04 14:32:50 UTC
LOGGER.log(Level.FINE, "Building model took {0}ms. Resolving types took {1}ms", new Object[]{(end - start), (end - startResolve)});

Creates array even when logging is disabled. Check logging level in advance.

Get rid of System.out.

Otherwise looks good.
Comment 5 Petr Pisl 2013-02-04 15:15:38 UTC
Thanks for the review. I have did the changes as Petr wrote. Also I increased the version of the index.
Comment 6 Vladimir Riha 2013-02-04 16:21:16 UTC
seems OK for me
Comment 7 Petr Pisl 2013-02-04 16:24:52 UTC

Both fixes transplanted to the releases repository.
Comment 8 Quality Engineering 2013-02-05 12:09:03 UTC
Integrated into 'releases', will be available in build *201302050851* or newer. Wait for official and publicly available build.
User: Petr Pisl <>
Log: #225707 - Resolving types in model is very slow
(transplanted from a49d3a59079ff2ee0237cc611f59d2013abc348d)
Comment 9 Quality Engineering 2013-02-05 12:36:32 UTC
Integrated into 'main-golden', will be available in build *201302050917* on (upload may still be in progress)
User: Petr Pisl <>
Log: #225707 - Resolving types in model is very slow
Comment 10 Vladimir Riha 2013-02-14 13:01:57 UTC
no regression found, verified

Product Version: NetBeans IDE 7.3 (Build 201302132200)
Java: 1.7.0_15; Java HotSpot(TM) Client VM 23.7-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_15-b02
System: Linux version 3.2.0-35-generic-pae running on i386; UTF-8; en_US (nb)

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo