Azure / autorest.csharp

Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
MIT License
142 stars 166 forks source link

Add ability to defer processing in protocol Pageable methods #2835

Open m-nash opened 2 years ago

m-nash commented 2 years ago

With this PR we did some perf analysis on the cost of calling having the convenience method wrap the protocol method vs directly call the rest api like other HLC clients do in dataplane / mgmt plane.

We found that since there is a double conversion happening we are adding about 50% additional time and 50% additional memory usage.

I would like to explore a way to trim this down to as close to zero as possible by introducing a way to defer processing to the iterator from this function here.

If we do that we should be able to get significant performance increases when it comes to simply calling the method without iterating. We need to validate that when we do this we don't make the full iteration case any slower than it is now, but it provides improvements if customers.

I would also like to explore a way to avoid the double conversion of first loading a BinaryData then deserializing it. We could explore having an internal concreate class of Page which based on whether T was BinaryData OR anything else it used the same defered jsonread to process one way or another. This makes sure we only iterate over the json a single time we just translate differently as we do it.

With these improvements I think we can later change the convenience methods to wrap the protocol methods since at this point the delta should be near zero.

chunyu3 commented 2 years ago

We plan to implement this on February next year.

lirenhe commented 1 year ago

No action before GA, move to the backlog.