Why does the NdrClientCall2() API call takes more then 4-5 milliseconds to complete?
Why does the NdrClientCall2() API call takes more then 4-5 milliseconds to complete in my application? In rare cases I even see hundreds of milliseconds (57 millisecond at one time) just for the NdrClientCall2() API call to complete.
In my application no server side processing is involved. My client and server both are running on the same machine. In either case it is a ncacn_np operation, both sides are already connected, all the calls should complete with the same (or about same) delays.
Is it possible to explain what kinds of things might be involved in this delay?
For local RPC calls, it is highly recommend that users to use ncalrpc and not ncacn_np. Ncacn_np is primarily for backwards compatibility and new applications should be using ncacn_ip_tcp for remote traffic. If you are using Vista or later, it is recommended to switch to the lower latency fast binding handle path for LRPC. This removes some significant sources of lock contention in the client path, potentially leading to a reduction in delays.
Please check the links below to know more about the fast RPC binding handle.
On the other hand, the occasional delay is not all that odd. A DPC firing, while the test is executing, can easily cause a 3-4ms delay.
Also please remember, Windows is not a real time operating system and there is no way to give any upper bound guarantee for NdrClientCall2() API call.