New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve performance using Collections in TomEE container #235
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
All great improvements, in my opinion.
Code compiles. Running full build in my machine. Will give feedback if something strange pops up.
Well... The build failed on the Container Core project, but it was a transient. The build is unstable right now |
@brunobat could you try again?
|
will do |
Fix for EarClassLoaderTest and EarWebAppFirstClassLoaderTest
This PR has the Goal to improve performance and save memory on the collections code. To get this goal, we went to different improvements:
These constructs method is replaced with a single call to a parametrized constructor which simplifies the code. Also for more performant such as HashSet.
Replaces add method to calling a bulk method (e.g. collection.addAll(listOfX). This will produce improvements in the code. Such as ArrayList and HashMap
Replace Arrays with one element to Collections.singletonList() which will save some memory.
Uses EnumSet instead of HashSet
From the documentation that says:
Replaces interaction over the keySet() of a java.util.Map instance, where the iterated keys are used to retrieve the values from the map. Such iteration may be more efficiently replaced by iteration over the entrySet() of the map. The Map.Entry is an entry within Map, that avoid the get method several times once the key and the value are in the object.
Benchmarking
Using the JMH, the OpenJDK benchmarking framework I created the code below:
List
Map