On Tue, Sep 2, 2014 at 3:06 PM, Tharindu Edirisinghe <[email protected]>
wrote:

> Hi,
>
> I'm going through the identity.provider source and found a possible
> performance issue. (However this has to be verified with some tool like
> JProfiler)
>
>
>
> turing/components/identity/org.wso2.carbon.identity.provider/4.2.2/src/main/java/org/wso2/carbon/identity/provider/openid/cache/OpenIDAssociationCache.java
>
>
>     /**
>      * Add the entry to the cache.
>      *
>      * @param association
>      */
>     public void addToCache(Association association) {
>         if (log.isDebugEnabled()) {
>             log.debug("Trying to add to cache.");
>         }
>         if (association != null && association.getHandle() != null) {
>             OpenIDIdentityCacheKey cacheKey = new
> OpenIDIdentityCacheKey(0, association.getHandle());
>             OpenIDIdentityCacheEntry cacheEntry =
>                                             new
> OpenIDIdentityCacheEntry(association.getType(),
>
> association.getMacKey(),
>
> association.getExpiry());
>             associationCache.addToCache(cacheKey, cacheEntry);
>             if (log.isDebugEnabled()) {
>                 log.debug("New entry is added to cache  : " +
> association.getHandle());
>             }
>         }
>     }
>
>
> The addToCache method is frequently called when creating OpenID
> associations. Every time a new association is created, it checks two times
> whether the debug log is enabled (shown in red above) by calling
> isDebugEnabled() method. (Assuming that the method call is costly than
> reading a local boolean variable)
>
> My suggestion is since the enabling or disabling the debug log is not
> happening during the runtime of the server, we keep a boolean variable
> inside the OpenIDAssociationCache class and assign value to that in the
> constructor of the class. Then each time the addToCache method is called,
> it will check that boolean value instead of always calling the
> log.isDebugEnabled() method.
>
> Any thoughts ??
>

+1  you could use a boolean variable in above code and eliminate duplicate
isDebugEnabled() calls.

BTW unless you call toString() method or String concatenations you can
avoid isDebugEnabled() calls when logging String constants.

e.g - log.debug("Trying to add to cache.");

Thanks !



> --
>
> Thanks & Best Regards,
>
> Tharindu Edirisinghe
> Software Engineer
>
> *WSO2 Inc*
> *email   : [email protected] <[email protected]> *
> *mobile : +94 775 181586*
> *www: :http://wso2.com <http://wso2.com/> *lean . enterprise . middleware
>
>
>
> _______________________________________________
> Architecture mailing list
> [email protected]
> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>
>


-- 
Sagara Gunathunga

Senior Technical Lead; WSO2, Inc.;  http://wso2.com
V.P Apache Web Services;    http://ws.apache.org/
Linkedin; http://www.linkedin.com/in/ssagara
Blog ;  http://ssagara.blogspot.com
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to