Performance - The affect of reducing remote calls
I just got 3000% performance improvement. I got if by turning this:
public int GetLatestVersion() { return SourceControlService.GetLatestChangeset(serverUrl, credentials); }
To this:
public int GetLatestVersion() { const string latestVersion = "Repository.Latest.Version"; if (PerRequest.Items[latestVersion] != null) return (int) PerRequest.Items[latestVersion]; int changeset = SourceControlService.GetLatestChangeset(serverUrl, credentials); PerRequest.Items[latestVersion] = changeset; return changeset; }
PerRequest.Items maps to HttpContext.Current.Items (it is a bit more complicated than that, we have non IIS hosted version to consider, but that is the same thing).
If you are wondering what it the most critical thing that you can do to get good performance, look at remote calls in the application.
Comments
Is it just me, or isn't this just screaming out for a bit of AOP, or at the very least a helper function taking a lambda. ;)
Actually, in this project I had some touch issues regarding caching via AOP.
There are a lot of decisions to make with regards to how to setup the proper key, so I just gave it up.
Also, there are 4(!) level of caching here, request, web, file system, meta data
I´ve built a Windsor Facility that enables method result caching (via AOP, using an interceptor). The obsolete CacheFacility source helped me, but it´s diferent. It maps (configurable) to the ASP .NET Cache object, we have plans to use a Distributed Cache soon. Here is it´s configuration on our windsor xml file:
Look at the cache xml TAG, inside it there is a list of method TAGs where methods are specified using it´s signature, then we set the cache expiration in seconds. The cached result key is a string containing the method´s name, parameters and values. CouponAware refers to context information, when it´s true it´s appended to the cache key too.
Working great on my dev machine :), we´ll stress test it next week....
Comment preview