Skip to content
This repository has been archived by the owner on Dec 30, 2018. It is now read-only.

cache alien element and attribute class to make it faster in OdfXMLFactory #3

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

ravenq
Copy link

@ravenq ravenq commented Apr 11, 2018

Hi,

Class.forName may not be an efficient method. and in org.odftoolkit.odfdom.pkg.OdfXMLFactory line:153 Class, it use Class.forName to find the Element/Atrribute Class. The classCache map make it better to find the Class. But we need a cache for Alien Element/Atrribute Class too, otherwise it will find the same alien Class by Class.forName again and again. It take too much of CPU cycle.

Related JIRA:https://issues.apache.org/jira/projects/ODFTOOLKIT/issues/ODFTOOLKIT-473

alien-performance-jprofiler

test-case-after-fix
test-case-befor-fix

Regards.

ravenq.

Copy link
Contributor

@svanteschubert svanteschubert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within the OdfXMLFactory the new inserted HashSet mAlienTypes is never filled, the new condition will never be met. Is there something missing?

Similar the test file will just give out the loading time and not test anything as the test will never fail.

We might need some performance tests, but I am not sure how to provide them using some existing open-source 3rd party perf-test tool..

@ravenq
Copy link
Author

ravenq commented Apr 13, 2018

Thanks for @svanteschubert !

The mAlienTypes will be filled when catch ClassNotFoundException/NoClassDefFoundError Exceptions.

There is much Alien Element and Attribute Node in the testAlienPerformance.odt. And the alien node always create by 3rd applications. In my work, it have a lot of odt file like this.It take too much time to load a odt file.

And for the performance test, I just want to show this problem. It is not a good test case for preformance test. so I will remove it if necessary.

Regards.

ravenq.

@svanteschubert
Copy link
Contributor

Mea Culpa, I misread the patch.
First time reviewing a patch via GitHub, but now I realized it is easy to access the patch by adding the ".patch" suffix the URL:
https://github.com/apache/odftoolkit/pull/3.patch

The mAlienTypes were once commented and you enabled them. I will have to think about it tomorrow, why somebody disabled this, when I have again a coffee in my hand.. ;-)

I am building your patch now and will likely look deeper into it tomorrow.

@ravenq
Copy link
Author

ravenq commented May 5, 2018

Thanks for @svanteschubert

There is nobody disabled it. I push 3 commits in this PR. and I disable it carelessly in my commit 2.
And I do not know how to squash it in GitHub.

Regards.
ravenq.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants