mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-23 06:05:45 +00:00
Don't call ReadLargeBuffer for socket reads
* In ReadLargeBuffer we read directly into an external buffer with ReadExternal, but for sockets when reading externally we want to read ahead of the current spot (non-blocking) as much as possible to batch small reads together. Rather than making ReadExternal handle or detect reads to external buffers, we instead avoid ReadLargeBuffer as it is an optimisation for direct I/O to avoid unnecessary memcpy's and is not relevant for sockets.
This commit is contained in:
@@ -270,7 +270,7 @@ bool StreamReader::Reserve(uint64_t numBytes)
|
||||
|
||||
bool StreamReader::ReadLargeBuffer(void *buffer, uint64_t length)
|
||||
{
|
||||
RDCASSERT(m_Sock || m_File || m_Decompressor);
|
||||
RDCASSERT(m_File || m_Decompressor);
|
||||
|
||||
byte *dest = (byte *)buffer;
|
||||
|
||||
@@ -398,6 +398,9 @@ bool StreamReader::ReadFromExternal(void *buffer, uint64_t length)
|
||||
// first get the required data blocking (this will sleep the thread until it comes in).
|
||||
byte *readDest = (byte *)buffer;
|
||||
|
||||
// we expect to be reading into our window buffer
|
||||
RDCASSERT(readDest >= m_BufferBase && readDest <= m_BufferBase + m_BufferSize);
|
||||
|
||||
success = m_Sock->RecvDataBlocking(readDest, (uint32_t)length);
|
||||
|
||||
if(success)
|
||||
@@ -407,6 +410,12 @@ bool StreamReader::ReadFromExternal(void *buffer, uint64_t length)
|
||||
|
||||
uint32_t bufSize = uint32_t(m_BufferSize - m_InputSize);
|
||||
|
||||
if(m_InputSize > m_BufferSize)
|
||||
{
|
||||
bufSize = 0;
|
||||
RDCERR("Invalid read in ReadFromExternal!");
|
||||
}
|
||||
|
||||
// now read more, as much as possible, to try and batch future reads
|
||||
success = m_Sock->RecvDataNonBlocking(readDest, bufSize);
|
||||
|
||||
|
||||
@@ -180,7 +180,9 @@ public:
|
||||
// and larger by just skating over the limit each time, but that's fine because the main
|
||||
// case we want to catch is a window that's only a few MB and then suddenly we read 100s of
|
||||
// MB.
|
||||
if(numBytes >= 10 * 1024 * 1024 && Available() + 128 < numBytes)
|
||||
// We don't do this on sockets since we want to opportunistically read more into the window
|
||||
// to batch lots of small reads together.
|
||||
if(m_Sock == NULL && numBytes >= 10 * 1024 * 1024 && Available() + 128 < numBytes)
|
||||
{
|
||||
success = ReadLargeBuffer(data, numBytes);
|
||||
alreadyread = true;
|
||||
|
||||
Reference in New Issue
Block a user