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 217515 - CSS source model creation based on reflection is slow
Summary: CSS source model creation based on reflection is slow
Status: RESOLVED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: CSS Visual Tools (show other bugs)
Version: 7.3
Hardware: PC Linux
: P2 normal (vote)
Assignee: Marek Fukala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-28 11:10 UTC by Vladimir Riha
Modified: 2012-10-03 14:52 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
profiler snapshot after adding new property - minor delay (46.52 KB, application/octet-stream)
2012-10-03 12:41 UTC, Vladimir Riha
Details
another snapshot (56.40 KB, application/octet-stream)
2012-10-03 12:46 UTC, Vladimir Riha
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2012-08-28 11:10:47 UTC
If you have a very large css file (like in Easel Rabbit Demo), then if you:
- run file (doesn't seem to matter of it is Chrome or embedded)
- select some element in Navigator and select some style
- and now Add Property from Rule Editor, it tooks a second (sometimes barely noticeable, sometimes it tooks 1-2sec) to reflect this new property in rule editor window while browser already shows the change.

Suggestion: I guess that when the css property is added (or removed) via Rule Editor, the css file is somehow "re-parsed". If it cannot be improved in terms of speed, would it be possible to add some sort of progress bar/icon so user know that the changes are in progress? Something like:
http://wiki.netbeans.org/File:Busy_window_notification.png


I've noticed there is some "busy" icon (next to the filter icons in Rule editor) that looks like icon of Databases node in Services window but it is not always displayed


Product Version: NetBeans IDE Dev (Build EaselCSS-577-on-20120827)
Java: 1.7.0_06; Java HotSpot(TM) Client VM 23.2-b09
System: Linux version 3.2.0-29-generic-pae running on i386; UTF-8; en_US (nb)
Comment 1 Marek Fukala 2012-10-03 07:03:52 UTC
just for curiosity the "database" icon should be removed - I've added it just for my debugging purposes. It is shown from the moment user modified the css source model until new model is created and applied to the RuleEditor. This involves file save, css parsing and css source model creation.
Comment 2 Marek Fukala 2012-10-03 12:26:44 UTC
99% of the slowness is:

 "org.netbeans.modules.web.inspect.webkit.ui.CSSStylesPanel" - Thread t@50
    java.lang.Thread.State: RUNNABLE
	at org.netbeans.modules.css.model.impl.ModelElement.acceptVisitorGeneric(ModelElement.java:105)
	at org.netbeans.modules.css.model.impl.ModelElement.accept(ModelElement.java:89)
	at org.netbeans.modules.css.model.impl.ModelElement.accept(ModelElement.java:86)
	at org.netbeans.modules.css.model.impl.ModelElement.accept(ModelElement.java:86)
	at org.netbeans.modules.css.model.impl.ModelElement.accept(ModelElement.java:86)
	at org.netbeans.modules.css.model.impl.ModelElement.accept(ModelElement.java:86)
	at org.netbeans.modules.css.model.impl.ModelElement.accept(ModelElement.java:86)
	at org.netbeans.modules.css.model.impl.ModelElement.accept(ModelElement.java:86)
	at org.netbeans.modules.web.inspect.webkit.Utilities.findRuleInStyleSheet0(Utilities.java:175)
	at org.netbeans.modules.web.inspect.webkit.Utilities.findRuleInStyleSheet(Utilities.java:103)
	at org.netbeans.modules.web.inspect.webkit.ui.CSSStylesPanel$RuleEditorTask$1.run(CSSStylesPanel.java:470)
	at org.netbeans.modules.css.model.api.Model$1.run(Model.java:192)
	at org.openide.util.Mutex.readAccess(Mutex.java:367)
	at org.netbeans.modules.css.model.api.Model.runReadTask(Model.java:189)
Comment 3 Marek Fukala 2012-10-03 12:29:21 UTC
It is really extremely slow on my mac, the fix needs to be done in the css source model.
Comment 4 Vladimir Riha 2012-10-03 12:41:54 UTC
Created attachment 125298 [details]
profiler snapshot after adding new property - minor delay
Comment 5 Vladimir Riha 2012-10-03 12:46:20 UTC
Created attachment 125301 [details]
another snapshot

another snapshot, just to be sure :) It is not that slow for me, but I noticed that once I pressed enter to confirm value of new property, RE contains this property immediately but after a while RE is refreshed (empty and repopulated with previous selection).

There is also a delay with first population of RE (reproducible with the same rabbit app and e.g. selecting .btn style from Styles window)
Comment 6 Marek Fukala 2012-10-03 13:27:08 UTC
changeset:   234960:066e07ff3341
summary:     #217515 - speeding up the o.n.m.css.model.api.ModelVisitor

I've removed the generic reflection based code from the visiting support. Less flexible, but 30times faster.

However the css model creation itself is still very slow as it is also based on reflection. I'd have to reconsider that much deeper.

I've created o.n.m.css.model.impl.ModelElementTest.testAcceptVisitorGeneric_speed test which shows that parsing & the source model creation of the bootstrap.css (from easel rabbit demo) takes approx. 2700ms on my Mac. Most of the time is the model creation, the parsing itself is very fast.
Comment 7 Marek Fukala 2012-10-03 13:32:42 UTC
I've double-checked and the parsing is not that fast as I used to think:

bootstrap.css:

file parsing took 870ms.
model creation took 1756ms.
Comment 8 Marek Fukala 2012-10-03 14:36:46 UTC
changeset:   234978:91ff1200866e
tag:         tip
user:        Marek Fukala <mfukala@netbeans.org>
date:        Wed Oct 03 16:32:54 2012 +0200
summary:     #217515 - removing the reflection from ElementsFactoryImpl

now the times are:

file parsing took 825ms.
model creation took 351ms.

...so the model creation is approximately 5 times faster than before.

I've verified also with the easel rabbit demo and I can confirm now it is far far better.
Comment 9 Marek Fukala 2012-10-03 14:45:30 UTC
> another snapshot, just to be sure :) It is not that slow for me, but I noticed
> that once I pressed enter to confirm value of new property, RE contains this
> property immediately but after a while RE is refreshed (empty and repopulated
> with previous selection).

Do you really see the whole rule editor to be empty for a while? Or just the property value "flashes" (I've fix this today or yesterday). Shouldn't this be filled as another bug?
Comment 10 Vladimir Riha 2012-10-03 14:52:51 UTC
Whole RE, reported as issue 219458. I thought if it could be related this issue...