Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337708 - Marker.setAttributes() causes new Thread creation
Summary: Marker.setAttributes() causes new Thread creation
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.6.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-21 06:54 EST by Andrey Pavlenko CLA
Modified: 2011-02-21 07:56 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Pavlenko CLA 2011-02-21 06:54:29 EST
Build Identifier: M20100909-0800

I'm developing an Eclipse-based editor, which uses IResource.createMarker() for error marking, and faced with problem - if a document contains too many errors (say > 1000) my editor becomes very slow and almost unusable. After debugging (the stack is below) I've found out that the cause of the performance degradation is org.eclipse.core.internal.resources.Marker.setAttributes() which causes a new short-living thread creation on each call. Thus, if there are > 1000 errors, > 1000 threads are created.

To fix the issue I would propose to use a short-living thread pool instead of a new thread creation.

Here is the stack trace:

	ProjectionSummary$Summarizer(Thread).init(ThreadGroup, Runnable, String, long) line: 312	
	ProjectionSummary$Summarizer(Thread).<init>() line: 377	
	ProjectionSummary$Summarizer.<init>(ProjectionSummary) line: 47	
	ProjectionSummary.updateSummaries() line: 144	
	ProjectionViewer$AnnotationModelListener.processModelChanged(IAnnotationModel, AnnotationModelEvent) line: 127	
	ProjectionViewer$AnnotationModelListener.modelChanged(AnnotationModelEvent) line: 116	
	AnnotationModel.fireModelChanged(AnnotationModelEvent) line: 612	
	AnnotationModel$InternalModelListener.modelChanged(AnnotationModelEvent) line: 261	
	StructuredResourceMarkerAnnotationModel(AnnotationModel).fireModelChanged(AnnotationModelEvent) line: 612	
	StructuredResourceMarkerAnnotationModel(AnnotationModel).fireModelChanged() line: 578	
	StructuredResourceMarkerAnnotationModel(ResourceMarkerAnnotationModel).update(IMarkerDelta[]) line: 114	
	ResourceMarkerAnnotationModel$ResourceChangeListener.resourceChanged(IResourceChangeEvent) line: 56	
	NotificationManager$2.run() line: 291	
	SafeRunner.run(ISafeRunnable) line: 42	
	NotificationManager.notify(ResourceChangeListenerList$ListenerEntry[], IResourceChangeEvent, boolean) line: 285	
	NotificationManager.broadcastChanges(ElementTree, ResourceChangeEvent, boolean) line: 149	
	Workspace.broadcastPostChange() line: 327	
	Workspace.endOperation(ISchedulingRule, boolean, IProgressMonitor) line: 1181	
	Marker.setAttributes(Map) line: 315



Reproducible: Always

Steps to Reproduce:
IResource file;
Map<String, Object> map = new HashMap<String, Object>(6);
MarkerUtilities.setMessage(map, message);
MarkerUtilities.setCharStart(map, start);
MarkerUtilities.setCharEnd(map, end);
map.put(IMarker.LOCATION, file.getLocationURI().toString());
map.put(IMarker.SEVERITY, severity);

IMarker marker = file.createMarker(IMarker.PROBLEM)
marker.setAttributes(map);
Comment 1 Szymon Brandys CLA 2011-02-21 07:12:38 EST
Summarizer Thread is used by ProjectionSummary from JFace Text.
Comment 2 Dani Megert CLA 2011-02-21 07:56:33 EST
You should create your markers inside a workspace runnable so that only one delta is sent out at the end.