axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shellman, Joel" <>
Subject Big performance improvement from Axis code change
Date Wed, 16 Apr 2003 15:48:05 GMT
I should send this to the dev list--but I'm not on that list yet (I'll sign up and post it),
and users might be interested in this, too.

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:

    private 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 = 
	                                   new Class[] {String.class, 
	        } catch (NoSuchMethodException e) {}
	        if (method == null) {
		            try {
		                Class helper = ClassUtils.forName(
		            		className + "_Helper");
		                method =
		                                     new Class[] {String.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

View raw message