You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by bu...@apache.org on 2003/04/16 19:00:21 UTC
DO NOT REPLY [Bug 19080] New: -
Performance bottleneck in BaseDeserializerFactory.getDeserializerMethod()
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19080>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19080
Performance bottleneck in BaseDeserializerFactory.getDeserializerMethod()
Summary: Performance bottleneck in
BaseDeserializerFactory.getDeserializerMethod()
Product: Axis
Version: 1.1rc2
Platform: All
OS/Version: All
Status: NEW
Severity: Enhancement
Priority: Other
Component: Serialization/Deserialization
AssignedTo: axis-dev@ws.apache.org
ReportedBy: joel.shellman@summit.fiserv.com
We ran axis under a profiler yesterday and found a serious bottleneck in
BaseDeserializerFactory:
The problem is that that method is being called with int and String many
(100's I think) times during our test. Calling it with int and string (maybe
others, that's all I saw in our test) results in a ClassNotFoundException.
Throwing exceptions is rather expensive so it's slowing it way down. I changed
the code to use a static cache and there was a huge improvement: 5-10 times
faster.
Here's the new code for that method and the declaration for the cache (it's
currently not synchronized--if it needs to be, you can use synchronization or
a HashTable if you like--given the nature of the cache, I'm not sure that's
necessary, though):
private transient static Map methodCache = new java.util.HashMap();
/**
* Returns the "getDeserializer" method if any.
*/
private Method getDeserializerMethod(Class clazz) {
String className = clazz.getName();
Method method = null;
if (!methodCache.containsKey(className)) {
try {
method =
clazz.getMethod("getDeserializer",
new Class[] {String.class,
Class.class,
QName.class});
} catch (NoSuchMethodException e) {}
if (method == null) {
try {
Class helper = ClassUtils.forName(
className + "_Helper");
method =
helper.getMethod("getDeserializer",
new Class[]
{String.class,
Class.class,
QName.class});
} catch (NoSuchMethodException e) {
} catch (ClassNotFoundException e) {
}
}
methodCache.put(className, method);
} else {
method = (Method)methodCache.get(className);
}
return method;
}
It seems to me that the real fix might be something else (I'm not familiar
with Axis code in general), but this simple change made a huge difference all
by itself. Running profiler afterwards didn't show any huge bottleneck like
this one.
Joel Shellman