1

Closed

We Call GetNamesFromIDs and GetIDsFromNames Way Too Often

description

Problem: Profiling showed GetNamesFromIDs and GetIDsFromNames were both pain points in rendering views. We make many calls to get mappings we just got on the last message. This is especially noticable on non-cached profiles.
 
Fix: Bite the bullet and implement a cache. Cache is exposed through two top level functions, named GetNamesFromIDs and GetIDsFromNames, identical to the IMAPIProp functions they replace, and a variant of GetNamesFromIDs which accepts a PR_MAPPING_SIGNATURE as a hint. Cache can be turned on and off from the registry and options dialog. Default is on. Biggest user of the cache is InterpretProp, which is replumbed to accept a mapping signature as well, so we can look at a single message, get it's mapping signature, and pass that hint along to the cache.
 
The cache maps triples of data: Signature, tag, Named ID. Given two of these, we can look up the entry in the cache. Additionally, since NameIDToStrings showed up as a pain point in profiling, and since the strings it generates will always be the same, we store those in the cache as well. FindCacheEntry is exposed to help this function look up strings without rebuilding them. Since these strings are now essentially constants if the cache is enabled, we have a new function, FreeNameIDStrings, to free them in the case the cache is turned off
 
The cache is initialized on demand. Everything in the cache is kept for program lifetime, cleaned up by a call to UninitializeNamedPropCache during shutdown.
 
Thought about ripping out the old optimization that makes a single batched call to GetNamesFromIDs in LoadMAPIPropList, but it turns out the effects of precaching from this single call are still positive (though, over time, minimized).
 
As noted, the cache may be turned off, in which case calls to the cache functions proxy directly to MAPI. We need this to troubleshoot providers with bad named property implementations.
Closed Jul 16, 2009 at 3:45 PM by sgriffin
Fixed in July 2009 Release

comments