This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 238910 - Code format is too slow
Summary: Code format is too slow
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Milos Kleint
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2013-11-28 04:18 UTC by _ gtzabari
Modified: 2013-12-02 15:46 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
.npss file attached from NetBeans (139.92 KB, application/x-npss)
2013-11-29 15:34 UTC, _ gtzabari
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2013-11-28 04:18:41 UTC
Product Version: NetBeans IDE 7.4 (Build 201310111528)
Updates: NetBeans IDE is updated to version NetBeans 7.4 Patch 1
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\7.4
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\7.4

Both the Javascript and Java code formatters are too slow. The Javascript formatter is extremely slow, about 10x slower than the Java formatter.

I expect to be able to code-format 1000 lines of code in one second. Ambitious, I know. I believe currently Java takes about 3-5 seconds and Javascript over 30 seconds.

I am filing this issue at a high level (not specific to Java or Javascript) because I suspect that we can make some high-level changes that will improve performance for all languages.

Could someone please profile the code and report the hotspots?

1. Can the operation be distributed across multiple cores?
2. Would it help to build the AST as the user is typing instead of doing so when code-format is invoked? (CPU power is growing at a much slower rate than memory)
Comment 1 Vladimir Riha 2013-11-29 13:21:06 UTC
I have a JS file with ~4500 lines and it takes ~2 secs to format it so it could be something with the particular file. Could you please create profiling snapshot [1] during the formatting and attach it here? Or perhaps the JS file, if possible?

If you want to improve formatting time in Java file (or others), please report it individually as single issues. 

Thank you.


[1] http://wiki.netbeans.org/FaqProfileMeNow
Comment 2 _ gtzabari 2013-11-29 15:34:06 UTC
Created attachment 142726 [details]
.npss file attached from NetBeans

.npss file
Comment 3 _ gtzabari 2013-11-29 15:35:28 UTC
I've attached a profiler snapshot for your review. Let me know what you find and if you really need it I will send you the relevant JS file privately (it is confidential and cannot be attached to this bug report).
Comment 4 _ gtzabari 2013-11-29 15:36:21 UTC
I forgot to mention: the file used to generate the profiler snapshot consists of 719 lines and took 15 seconds to code-format using ALT+SHIFT+F.
Comment 5 Petr Hejl 2013-12-02 12:50:54 UTC
Well it looks like project loading cause delay on getting initial indentation and other formatting preferences.
Comment 6 Martin Janicek 2013-12-02 12:57:23 UTC
I can't see anything related to Java EE part's of Maven, reassigning to Milos
Comment 7 Milos Kleint 2013-12-02 15:46:28 UTC
http://hg.netbeans.org/core-main/rev/f5d837a0fa59

while we cached the values themselves, we didn't cache the call the decided if checkstyle formatting is enabled or not, now we do.

please test with your setup