Bug 152062 - [performance] HTML validator is not validating delta changes, it's re-validating the entire document
Summary: [performance] HTML validator is not validating delta changes, it's re-validat...
Status: RESOLVED WONTFIX
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.html (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---   Edit
Assignee: Nitin Dahyabhai CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2006-07-27 16:40 EDT by Jeffrey Liu CLA
Modified: 2010-06-02 17:10 EDT (History)
2 users (show)

See Also:


Attachments
JSP file (1.42 KB, text/plain)
2006-07-27 16:42 EDT, Jeffrey Liu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Liu CLA 2006-07-27 16:40:44 EDT
Build: 0712 1.5.1 I-build

The HTML validator is not validating delta changes, it's re-validating the entire document. To reproduce the scenario:

1. Debug a runtime workbench
2. Create a Web project
3. Put the following JSP file into the WebContent folder
4. Open up the JSP file
5. Put a break point at the org.eclipse.wst.html.internal.validation.HTMLValidator.validate(IRegion dirtyRegion, IValidationContext helper, IReporter reporter) method.
6. In the JSP editor, go to the very top of the document
7. Hit enter
8. You'll run into the break point many times. Resume execution every time you run into the break point. Pay attention to the value of the "dirtyRegion" input argument. It goes like this:

round 1 - \r\n
round 2 - <%@ page contentType="text/html; charset=UTF-8" import="java.util.Hashtable,
                                                        java.util.List,
                                                        java.util.ArrayList,
                                                        java.net.URL,
                                                        javax.xml.parsers.*,
                                                        org.w3c.dom.*" %>
round 3 - \r\n\r\n
round 4 - <jsp:useBean id="table0" class="Hashtable" scope="session"/>

and so on... Basically, the HTMLValidator is re-validating the entire document every time I hit enter at the very top of the document.

9. After the HTMLValidator completes, go to the first <jsp:useBean .../>, hit enter. Again the entire document is re-validated. This is very expensive if you have a large JSP file.
Comment 1 Jeffrey Liu CLA 2006-07-27 16:42:05 EDT
I think this deserves a P2. I'll attach the sample JSP file.
Comment 2 Jeffrey Liu CLA 2006-07-27 16:42:45 EDT
Created attachment 46912 [details]
JSP file
Comment 3 Jeffrey Liu CLA 2006-08-01 13:49:13 EDT
In org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor, there's a TODO:

public void documentChanged(DocumentEvent event) {
	if (partitionsChanged(event)) {
		// pa_TODO
		// this is a simple way to ensure old
		// annotations are removed when partition changes

		// it might be a performance hit though
		setEntireDocumentDirty(getDocument());
	}
	...
Comment 4 Ian Tewksbury CLA 2010-02-01 09:04:46 EST
The code mentioned in comment #3 still exists and it would be worth while seeing if there is a more efficient approach.
Comment 5 Nitin Dahyabhai CLA 2010-06-02 17:10:18 EDT
Given the complicated tree structure it maintains in the background along with embedded other languages and the limitations on which annotations can be changed by a partially-scoped validator, it's just non-trivial to properly validate the document incrementally.  It's properly marked as "total" scope so that it's only run once each time we process the set of dirty regions.