Changes between Version 1 and Version 2 of Ticket #9801, comment 2


Ignore:
Timestamp:
Oct 4, 2023, 4:32:14 PM (2 years ago)
Author:
Tom Goddard

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #9801, comment 2

    v1 v2  
    11The C# reading code allocates an array for the full size of the message and fills it as data is read, so there is no concatenation to slow down the read.
    22
    3 One possibility is that the async read is not getting CPU time very often because the Unity is not querying the task often enough, maybe only once per rendering update loop.  The code currently reads while data is available and then does a stream.ReadSync() call. I could test that by always doing a synchronous stream.Read() until the whole message is read.  Try that.  The same problem could be slowing the writing to the socket using WriteAsync().  Can change that to Write() as a test.
     3One possibility is that the async read is not getting CPU time very often because the Unity is not querying the task often enough, maybe only once per rendering update loop.  The code currently reads while data is available and then does a stream.ReadSync() call. I could test that by always doing a synchronous stream.Read() until the whole message is read.  Try that.  The same problem could be slowing the writing to the socket using WriteAsync().  Can change that to Write() as a test.  With synchronous read and write it took the same amount of time.
     4
     5Maybe the large JSON message encoding and parsing is slow?