Async JSON read/write/(de)serialize #66885
Replies: 3 comments 6 replies
-
I believe that if a method returns ValueTask, you can expect it to run completely synchronously without allocating a state machine for as long as it can. In this case, it would be specifically when the PipeWriter buffer is empty. |
Beta Was this translation helpful? Give feedback.
-
I ran a quick benchmark and it looks like when writing to a |
Beta Was this translation helpful? Give feedback.
-
To answer my own question: it does not seem to be worth it to make methods of a JsonWriter-like class asynchonous, even with ValueTask, and this includes HtmlTextWriter. I've actually written an async HtmlTextWriter implementation and code to use it, and am going to revert to synchronous. The performance penalty, rendering a moderately sized HTML page, is humongous; something on the order of going from 1ms to about 100ms. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Does it make sense to make JSON operations async, with
ValueTask
and writing to aPipeWriter
? I'm concerned about potential performance hit of all the allocations of async state machines. Has anybody looked into it at all?Beta Was this translation helpful? Give feedback.
All reactions