XCOMMONS-2349: Improve performance of AttributeFilter in HTMLCleaner #159
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This includes two implementations in two commits, the first is based on
ThreadLocal
, which is changed to use the execution context in the second commit, which I believe should be the better option. As it is not clear thatXPathFactory.newInstance();
is thread-safe, I have also added asynchronized
-block which should also be added to all other uses if we agree that this is an issue.Note: I'm not sure that this is the right approach. I'll stop investigating here for now, but I did a quick profile (in debug mode, no idea how much this impacts performance) of the 1000 HTML macros test page and it seemed to me as if XPath evaluation accounts for almost 90% of the
HTMLFilter
running time. This is quite bad imho asHTMLFilter
still needs about as much time as the rest of the Macro transformation. I think this is way too much even though it is a roughly factor 10 improvement (factor 5 overall less running time). Therefore, we might either need to cache even more (maybe cache theXPathExpression
as in the first commit, didn't benchmark that) or use a different implementation for this filter.Jira issue: https://jira.xwiki.org/browse/XCOMMONS-2349