I get heavy CPU usage when accessing the Cisco AXL SOAP API using WCF. I start by creating a client base for the service model using the generated classes from wsdl. I use basichttpbinding and transfermode as buffered. When a call is made, the CPU fails, and the CPU profile shows that 96% of the processor time is in _TransparentProxyStub_CrossContext@0 from clr.dll, called after calls such as base.Channel.getPhone(request); . Rather, the call displays the core of the processor in which the process is running.
Here, the debug client creation from wsdl will generate
[System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] public partial class AXLPortClient : System.ServiceModel.ClientBase<AxlNetClient.AXLPort>, AxlNetClient.AXLPort { public AXLPortClient() { } public AXLPortClient(string endpointConfigurationName) : base(endpointConfigurationName) { } ...
This is how I create a client:
public class AxlClientFactory : IAxlClientFactory { private const string AxlEndpointUrlFormat = "https://{0}:8443/axl/"; public AXLPortClient CreateClient(IUcClientSettings settings) { ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true; ServicePointManager.Expect100Continue = false; var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; basicHttpBinding.MaxReceivedMessageSize = 20000000; basicHttpBinding.MaxBufferSize = 20000000; basicHttpBinding.MaxBufferPoolSize = 20000000; basicHttpBinding.ReaderQuotas.MaxDepth = 32; basicHttpBinding.ReaderQuotas.MaxArrayLength = 20000000; basicHttpBinding.ReaderQuotas.MaxStringContentLength = 20000000; basicHttpBinding.TransferMode = TransferMode.Buffered;
The generated wsdl code for the AXL API is very large. Both initial and subsequent calls have a CPU problem, although subsequent calls are faster. Is there anything else I can do to debug this problem? Is there a way to reduce this CPU usage?
Update
A bit more info about the bonus:
I created C # classes as follows:
svcutil AXLAPI.wsdl AXLEnums.xsd AXLSoap.xsd /t:code /l:C
You need to download wsdl for Cisco AXL api from the call manager system. I am using API version 10.5. I believe that the main slowdown is related to XML processing. WSDL for api is huge, as a result of the resulting classes produce 538,406 lines of code!
Update 2
I have enabled WCF tracing with all levels. The biggest time difference is the activity of the process’s action between “The message was written” and “Message sent through the channel”, in which an almost full minute passes between these two actions. Other actions (channel creation, open client base and closed client base) are performed relatively quickly.
Update 3
I made two changes to the generated client classes. First, I removed ServiceKnownTypeAttribute from all operations contracts. Secondly, I removed XmlIncludeAtribute from some serializable classes. These two changes reduced the file size of the generated client by more than 50% and had a small effect on the testing time (reduction of about 10 seconds by the test result of 70 s).
I also noticed that I have approximately 900 work contracts for one service interface and endpoint. This is due to wsdl for the AXL API, which combines all operations in a single namespace. I think about it, but it will mean the creation of several client bases, each of which will implement a reduced interface and eventually break everything that implements this wcf library.
Update 4
It seems that the number of operations is a central issue. I was able to separate operations and definitions of interfaces by verb (for example, gets, adds, etc.) to my client base and interface (a very slow process using sublime text and regular expressions, because resharper and codemaid cannot process a large file, which still 250K + lines). A Get client test with approximately 150 operations installed resulted in a 10 second run for getPhone compared to the previous 60 second result. This is still much slower than it should be, since it is easy to process this operation in the violinist's results in 2 second execution. The solution is likely to further reduce the number of operations by trying to separate operations further. However, this adds a new hacking problem to all systems that used this library as a single client.