You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using jaxrs-analyzer-maven-plugin/jaxrs-analyzer to generate swagger for our service endpoints.
The generation process got exponentially slower with every service class we added to the scanned packages.
When it got unbearable we investigated and found the culprit in the class com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.simulation.MethodPool
There the LinkedList availableMethods is being used as 'cache' which scanned/iterated completely for every get(MethodIdentifier) in the worst case => O(n).
Also addProjectMethod does not check if a method is already in the list, which results in duplicate entries.
This resulted in a runtime of
~ 160s with 28512 entries.
Making availableMethods a Map/HashMap resulted in a runtime of
~ 14s with now only 7769 entries.
=> both faster and smaller memorywise
To make using a HashMap possible we introduced a method MethodIdentifier getIdentifier()
in the interface com.sebastian_daschner.jaxrs_analyzer.model.methods.IdentifiableMethod
and implemented it for all classes implementing IdentifiableMethod.
The resulting swagger.json was almost the same but for one minor difference;
On of the scanned services returns a object with a member private Map<Integer, List<Message>> messages
With the original code this was translated to
which is close, but still...
in the changed code it became
"messages": {
"type": "object"
}
really can't explain is the reason for this is...
If you are interested I could create a pull request, but since it changes your design I wanted to run it by you.
Cheers & thanks for this very nice tool!
The text was updated successfully, but these errors were encountered:
bseiller
changed the title
significant performance improvement by making availableMethods of MethodPool a Map/HashMap
significant performance improvement by making availableMethods in MethodPool a Map/HashMap
May 8, 2018
We are using jaxrs-analyzer-maven-plugin/jaxrs-analyzer to generate swagger for our service endpoints.
The generation process got exponentially slower with every service class we added to the scanned packages.
When it got unbearable we investigated and found the culprit in the class
com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.simulation.MethodPool
There the LinkedList availableMethods is being used as 'cache' which scanned/iterated completely for every
get(MethodIdentifier)
in the worst case => O(n).Also
addProjectMethod
does not check if a method is already in the list, which results in duplicate entries.This resulted in a runtime of
~ 160s with 28512 entries.
Making availableMethods a Map/HashMap resulted in a runtime of
~ 14s with now only 7769 entries.
=> both faster and smaller memorywise
To make using a HashMap possible we introduced a method
MethodIdentifier getIdentifier()
in the interface
com.sebastian_daschner.jaxrs_analyzer.model.methods.IdentifiableMethod
and implemented it for all classes implementing IdentifiableMethod.
The resulting swagger.json was almost the same but for one minor difference;
On of the scanned services returns a object with a member
private Map<Integer, List<Message>> messages
With the original code this was translated to
which is close, but still...
in the changed code it became
really can't explain is the reason for this is...
If you are interested I could create a pull request, but since it changes your design I wanted to run it by you.
Cheers & thanks for this very nice tool!
The text was updated successfully, but these errors were encountered: