-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Proposal: Add Async validation #329
Comments
This is interesting, as we initially had an async interface, but due to the fact that many validations (cardinality, string length, patterns, etc) were merely very short computes, the overhead of Task/await on all those nested validates became noticable, so we removed it. I guess it depends on the ratio of I/O bound validations and simple, compute validations. And as we know, async tends to spread everywhere, so we cannot have non-async validates for simple computes, and async validates for i/o bound ones. At least I think so, I'd love to be proven wrong ;-) As it stands, I don't feel like re-introducing async anytime soon after our previous experiences. |
In your previous testing, did you use For now, the main advantage to using async is that it preserves the traces in flame graphs which makes it easier to diagnose performance issues. In the synchronous version, the occasional calls to TaskHeper.Await changes the stack traces |
My QR validator has a hybrid of both approaches. |
One benefit to an async validtion API is that potentially, validation could take a long time and it is possible that the client has cancelled the validation request. Respecting the cancellation token can help with scalability. |
We think async will lead to too much overhead current, since most validation are so fast that starting up a task will take more time than actually validating the validation blocks. |
The new validator should include an async API to avoid calls to
TaskHelper.Await
. During my performance profiling sessions, I found usingTaskHelper.Await
, or evenTask.GetAwater().GetResult()
makes the traces chaotic. Also, I feel it has a significant scalability impact when used with network bound resource resolvers.Proposed new API
The three interfaces use the default interface method implementation for the new API. If the validator does not need to be async (i.e., it doesn't call any async api such as other other validators), it doesn't need to implement the new async method.
Performance
The async validate API also appears to be faster according to benchmarks:
The text was updated successfully, but these errors were encountered: