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 100252 - AttributeUtils.createComposite suboptimal
Summary: AttributeUtils.createComposite suboptimal
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Settings (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Vitezslav Stejskal
URL:
Keywords: PERFORMANCE, SIMPLEFIX
Depends on:
Blocks:
 
Reported: 2007-04-06 19:42 UTC by Petr Nejedly
Modified: 2007-11-05 13:42 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Optimization of AttributeUtils (857 bytes, patch)
2007-04-06 19:44 UTC, Petr Nejedly
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Nejedly 2007-04-06 19:42:30 UTC
The code in AttributeUtils.createComposite tries to create no instances if it
isn't strictly necessary - returns the original instance if the passed array is
empty and so on.
But in case the passed array is longer, yet the resulting list has only one
entry, it still produces AttributeUtils$Composite.
This causes nontrivial overhead. For 1.3MB XSD file, I have found >200.000
instances of AttributeSet[] and as many AttributeUtils$Composite on heap, most
of them representing exactly this case, which accounted for 5MB.

Such instances were created this way:
Short list from:
[org.netbeans.api.editor.settings.AttributesUtilities$Immutable@17df2ba, null]
java.lang.Exception: Stack trace
org.netbeans.api.editor.settings.AttributesUtilities.createComposite(AttributesUtilities.java:134)
org.netbeans.spi.editor.highlighting.support.OffsetsBag.merge(OffsetsBag.java:444)
org.netbeans.spi.editor.highlighting.support.OffsetsBag.addHighlightImpl(OffsetsBag.java:428)
org.netbeans.spi.editor.highlighting.support.OffsetsBag.addAllHighlightsImpl(OffsetsBag.java:521)
org.netbeans.spi.editor.highlighting.support.OffsetsBag.addAllHighlights(OffsetsBag.java:143)
org.netbeans.modules.editor.lib2.highlighting.CompoundHighlightsContainer.updateCache(CompoundHighlightsContainer.java:269)
org.netbeans.modules.editor.lib2.highlighting.CompoundHighlightsContainer.getHighlights(CompoundHighlightsContainer.java:144)


I'll attach a fix for this problem (5 megs back home...), but somebody should
check the caller, null in the incomming array look suspicious...
Comment 1 Petr Nejedly 2007-04-06 19:44:01 UTC
Created attachment 40572 [details]
Optimization of AttributeUtils
Comment 2 Vitezslav Stejskal 2007-04-10 03:27:39 UTC
Silly me, thanks for the patch. OffsetsBag probably should not use
AU.createComposite when merging highlights with 'empty' (non-highlighted) areas.
I'll change it.

Checking in AttributesUtilities.java;
/cvs/editor/settings/src/org/netbeans/api/editor/settings/AttributesUtilities.java,v
 <--  AttributesUtilities.java
new revision: 1.2; previous revision: 1.1
done
Comment 3 Vitezslav Stejskal 2007-04-10 04:14:15 UTC
Checking in OffsetsBag.java;
/cvs/editor/lib2/src/org/netbeans/spi/editor/highlighting/support/OffsetsBag.java,v
 <--  OffsetsBag.java
new revision: 1.4; previous revision: 1.3
done
Checking in PositionsBag.java;
/cvs/editor/lib2/src/org/netbeans/spi/editor/highlighting/support/PositionsBag.java,v
 <--  PositionsBag.java
new revision: 1.4; previous revision: 1.3
done