openwhisk-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [openwhisk-runtime-dotnet] kamyker opened a new issue #26: Raw requests to skip JObject conversion
Date Wed, 27 Nov 2019 04:55:50 GMT
kamyker opened a new issue #26: Raw requests to skip JObject conversion
URL: https://github.com/apache/openwhisk-runtime-dotnet/issues/26
 
 
   Another thing that could be added to speed up large requests processing time.
   
   Currently there is:
   ```
   string body = await new StreamReader(httpContext.Request.Body).ReadToEndAsync();
   JObject inputObject = string.IsNullOrEmpty(body) ? null : JObject.Parse(body);
   ```
   It's fine for small requests but for big ones it will allocate a lot of memory and increase
time to complete any function. While that code itself could be improved by reading from Stream
directly using current JsonNet (more https://www.newtonsoft.com/json/help/html/Performance.htm
in "Optimize Memory Usage") it would be great to somehow skip this process completely, pass
httpContext.Request (instead of JObject) and let user do whatever he wants to. In addition
to that instead of returning JObject that's converted to string and then to byte[]
   ```
     await httpContext.Response.WriteResponse(200, output.ToString());
     (...)
     byte[] bytes = Encoding.UTF8.GetBytes(content);
     await response.WriteAsync(content);
   ```
   function could simply return raw bytes.
   
   So basically high performance mode, in the end function definition:
   `public async Task<byte[]> Main(HttpRequest request)`
   
   Why is it important? I've just notice in Azure Functions it takes almost 2500ms to simply
receive 1mb json. No idea what their sdk is doing exactly but that amount of overhead seems
weird to me, they also use JsonNet.
   
   With this feature I could use for ex. https://github.com/neuecc/Utf8Json to work on byte[]
and Streams to make my function in OpenWhisk run ~5 times faster and allocate ~20 times less
memory :).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message