|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
[donjon] [Facilities] FACILITIES-ISSUE-130 Changed "WCF Facility: proxies types not being cached"Hi there, The user Simon Cropp (simoncropp) has changed the issue FACILITIES-ISSUE-130 "WCF Facility: proxies types not being cached". Here is what the user changed: Description from: We having some perf problems problems getting web service proxies I noted that proxies are meant to be cached but from stepping through the code ours were not. It seemed to be caused by Equals and GetHashCode in ProxyGenerationOptions returning false and different values respectivly. Even when we were requesting the same Type+interfaces combination. DynamicProxy\src\Castle.DynamicProxy\ProxyGenerationOptions.cs public override bool Equals(object obj) { if (ReferenceEquals(this, obj)) return true; var proxyGenerationOptions = obj as ProxyGenerationOptions; if (ReferenceEquals(proxyGenerationOptions, null)) return false; // ensure initialization before accessing MixinData Initialize(); proxyGenerationOptions.Initialize(); if (!Equals(Hook, proxyGenerationOptions.Hook)) return false; if (!Equals(Selector, proxyGenerationOptions.Selector)) return false; if (!Equals(MixinData, proxyGenerationOptions.MixinData)) return false; if (!Equals(BaseTypeForInterfaceProxy, proxyGenerationOptions.BaseTypeForInterfaceProxy)) return false; return true; } public override int GetHashCode() { // ensure initialization before accessing MixinData Initialize(); int result = Hook != null ? Hook.GetType().GetHashCode() : 0; result = 29 * result + (Selector != null ? Selector.GetHashCode() : 0); result = 29 * result + MixinData.GetHashCode(); result = 29 * result + (BaseTypeForInterfaceProxy != null ? BaseTypeForInterfaceProxy.GetHashCode() : 0); return result; } During my debugging Hook is of type Castle.Facilities.WcfIntegration.Async.AsyncChannelFactoryProxyHook or Castle.Facilities.WcfIntegration.Async.WcfProxyGenerationHook Selector is of type Castle.Facilities.WcfIntegration.Proxy.WcfInterceptorSelector But neither AsyncChannelFactoryProxyHook nor WcfInterceptorSelector override GetHashcode or Equals and they are different instances. Since each time we come in these seem to be different instances is causes issues with \DynamicProxy\src\Castle.DynamicProxy\ModuleScope.cs public Type GetFromCache(CacheKey key) { Type type; if (typeCache.TryGetValue(key, out type)) return type; else return null; } public void RegisterInCache(CacheKey key, Type type) { typeCache[key] = type; } Basically we never get a cached type and typeCache keeps on growing. In the attached patch I have -made WcfProxyGenerationHook a single instance per WcfProxyFactory -made AsyncChannelFactoryProxyHook a single instance per AsynChannelFactoryBuilder -implemented GetHashCode and Equals on WcfInterceptorSelector to: We having some perf problems problems getting web service proxies I noted that proxy types are meant to be cached but from stepping through the code ours were not. It seemed to be caused by Equals and GetHashCode in ProxyGenerationOptions returning false and different values respectivly. Even when we were requesting the same Type+interfaces combination. DynamicProxy\src\Castle.DynamicProxy\ProxyGenerationOptions.cs public override bool Equals(object obj) { if (ReferenceEquals(this, obj)) return true; var proxyGenerationOptions = obj as ProxyGenerationOptions; if (ReferenceEquals(proxyGenerationOptions, null)) return false; // ensure initialization before accessing MixinData Initialize(); proxyGenerationOptions.Initialize(); if (!Equals(Hook, proxyGenerationOptions.Hook)) return false; if (!Equals(Selector, proxyGenerationOptions.Selector)) return false; if (!Equals(MixinData, proxyGenerationOptions.MixinData)) return false; if (!Equals(BaseTypeForInterfaceProxy, proxyGenerationOptions.BaseTypeForInterfaceProxy)) return false; return true; } public override int GetHashCode() { // ensure initialization before accessing MixinData Initialize(); int result = Hook != null ? Hook.GetType().GetHashCode() : 0; result = 29 * result + (Selector != null ? Selector.GetHashCode() : 0); result = 29 * result + MixinData.GetHashCode(); result = 29 * result + (BaseTypeForInterfaceProxy != null ? BaseTypeForInterfaceProxy.GetHashCode() : 0); return result; } During my debugging Hook is of type Castle.Facilities.WcfIntegration.Async.AsyncChannelFactoryProxyHook or Castle.Facilities.WcfIntegration.Async.WcfProxyGenerationHook Selector is of type Castle.Facilities.WcfIntegration.Proxy.WcfInterceptorSelector But neither AsyncChannelFactoryProxyHook nor WcfInterceptorSelector override GetHashcode or Equals and they are different instances. Since each time we come in these seem to be different instances is causes issues with \DynamicProxy\src\Castle.DynamicProxy\ModuleScope.cs public Type GetFromCache(CacheKey key) { Type type; if (typeCache.TryGetValue(key, out type)) return type; else return null; } public void RegisterInCache(CacheKey key, Type type) { typeCache[key] = type; } Basically we never get a cached type and typeCache keeps on growing. In the attached patch I have -made WcfProxyGenerationHook a single instance per WcfProxyFactory -made AsyncChannelFactoryProxyHook a single instance per AsynChannelFactoryBuilder -implemented GetHashCode and Equals on WcfInterceptorSelector For more, see http://support.castleproject.org/projects/FACILITIES/issues/view/FACILITIES-ISSUE-130 -- donjon by Castle Stronghold http://www.castle-donjon.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Development List" group. To post to this group, send email to castle-project-devel@... To unsubscribe from this group, send email to castle-project-devel+unsubscribe@... For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |