Write initial mesh data to file in larger chunks. Reduces file i/o stalls.
This commit is contained in:
@@ -2197,12 +2197,13 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason,
|
||||
|
||||
S32 data_size = buffer->countAfter(channels.in(), NULL);
|
||||
|
||||
U8* data = NULL;
|
||||
static U8 data[16384];
|
||||
llassert_always(data_size <= sizeof(data));
|
||||
memset(data + data_size, 0, sizeof(data)-data_size);
|
||||
|
||||
if (data_size > 0)
|
||||
{
|
||||
AIStateMachine::StateTimer timer("readAfter");
|
||||
data = new U8[data_size];
|
||||
buffer->readAfter(channels.in(), NULL, data, data_size);
|
||||
}
|
||||
|
||||
@@ -2219,7 +2220,7 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason,
|
||||
<< "Unable to parse mesh header: "
|
||||
<< status << ": " << reason << llendl;
|
||||
}
|
||||
else if (data && data_size > 0)
|
||||
else if (data_size > 0)
|
||||
{
|
||||
//header was successfully retrieved from sim, cache in vfs
|
||||
LLUUID mesh_id = mMeshParams.getSculptID();
|
||||
@@ -2258,28 +2259,20 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason,
|
||||
LLMeshRepository::sCacheBytesWritten += data_size;
|
||||
|
||||
AIStateMachine::StateTimer timer("WriteData");
|
||||
file.write((const U8*) data, data_size);
|
||||
|
||||
//zero out the rest of the file
|
||||
U8 block[4096];
|
||||
memset(block, 0, 4096);
|
||||
|
||||
while (bytes-file.tell() > 4096)
|
||||
S32 bytes_remaining = bytes;
|
||||
while (bytes_remaining > 0)
|
||||
{
|
||||
file.write(block, 4096);
|
||||
}
|
||||
|
||||
S32 remaining = bytes-file.tell();
|
||||
|
||||
if (remaining > 0)
|
||||
{
|
||||
file.write(block, remaining);
|
||||
const S32 bytes_written = llmin(bytes_remaining, (S32)sizeof(data));
|
||||
file.write(data, bytes_written);
|
||||
if (bytes_remaining == bytes && bytes_written < bytes_remaining)
|
||||
{
|
||||
memset(data, 0, data_size);
|
||||
}
|
||||
bytes_remaining -= llmin(bytes_remaining, bytes_written);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete [] data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user