forked from 0ad/0ad
# miscellaneous improvements
- increase io depth and block size to better utilize FusionIO's crazy bandwidth - add OS error number to crashlog (error message may be localized and illegible) This was SVN commit r7054.
This commit is contained in:
parent
f626396cad
commit
468a67d18c
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* cache for aligned I/O m_blocks.
|
||||
* cache for aligned I/O blocks.
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "block_cache.h"
|
||||
#include "io_align.h"
|
||||
|
||||
static const size_t ioDepth = 8;
|
||||
static const size_t ioDepth = 16;
|
||||
|
||||
|
||||
// the underlying aio implementation likes buffer and offset to be
|
||||
@ -125,43 +125,48 @@ public:
|
||||
{
|
||||
m_file = file;
|
||||
m_blockId = BlockId(file->Pathname(), alignedOfs);
|
||||
if(file->Mode() == 'r' && s_blockCache.Retrieve(m_blockId, m_cachedBlock))
|
||||
if(file->Mode() == 'r')
|
||||
{
|
||||
stats_block_cache(CR_HIT);
|
||||
|
||||
// copy from cache into user buffer
|
||||
if(alignedBuf)
|
||||
if(s_blockCache.Retrieve(m_blockId, m_cachedBlock))
|
||||
{
|
||||
cpu_memcpy(alignedBuf, m_cachedBlock.get(), BLOCK_SIZE);
|
||||
m_alignedBuf = alignedBuf;
|
||||
stats_block_cache(CR_HIT);
|
||||
|
||||
// copy from cache into user buffer
|
||||
if(alignedBuf)
|
||||
{
|
||||
cpu_memcpy(alignedBuf, m_cachedBlock.get(), BLOCK_SIZE);
|
||||
m_alignedBuf = alignedBuf;
|
||||
}
|
||||
// return cached block
|
||||
else
|
||||
{
|
||||
m_alignedBuf = const_cast<u8*>(m_cachedBlock.get());
|
||||
}
|
||||
|
||||
return INFO::OK;
|
||||
}
|
||||
// return cached block
|
||||
else
|
||||
{
|
||||
m_alignedBuf = const_cast<u8*>(m_cachedBlock.get());
|
||||
stats_block_cache(CR_MISS);
|
||||
// fall through to the actual issue..
|
||||
}
|
||||
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
stats_io_check_seek(m_blockId);
|
||||
|
||||
// transfer directly to/from user buffer
|
||||
if(alignedBuf)
|
||||
{
|
||||
m_alignedBuf = alignedBuf;
|
||||
}
|
||||
// transfer into newly allocated temporary block
|
||||
else
|
||||
{
|
||||
stats_block_cache(CR_MISS);
|
||||
stats_io_check_seek(m_blockId);
|
||||
|
||||
// transfer directly to/from user buffer
|
||||
if(alignedBuf)
|
||||
{
|
||||
m_alignedBuf = alignedBuf;
|
||||
}
|
||||
// transfer into newly allocated temporary block
|
||||
else
|
||||
{
|
||||
m_tempBlock = io_Allocate(BLOCK_SIZE);
|
||||
m_alignedBuf = const_cast<u8*>(m_tempBlock.get());
|
||||
}
|
||||
|
||||
return file->Issue(m_req, alignedOfs, m_alignedBuf, BLOCK_SIZE);
|
||||
m_tempBlock = io_Allocate(BLOCK_SIZE);
|
||||
m_alignedBuf = const_cast<u8*>(m_tempBlock.get());
|
||||
}
|
||||
|
||||
return file->Issue(m_req, alignedOfs, m_alignedBuf, BLOCK_SIZE);
|
||||
}
|
||||
|
||||
LibError WaitUntilComplete(const u8*& block, size_t& blockSize)
|
||||
|
@ -28,7 +28,7 @@
|
||||
* (blocks are also thereby page-aligned, which allows write-protecting
|
||||
* file buffers without worrying about their boundaries.)
|
||||
**/
|
||||
static const size_t BLOCK_SIZE = 256*KiB;
|
||||
static const size_t BLOCK_SIZE = 1024*KiB;
|
||||
|
||||
// note: *sizes* and *offsets* are aligned to blocks to allow zero-copy block cache.
|
||||
// that the *buffer* need only be sector-aligned (we assume 4kb for simplicity)
|
||||
|
@ -297,13 +297,19 @@ LibError sys_error_description_r(int user_err, char* buf, size_t max_chars)
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
const LPCVOID source = 0; // ignored (we're not using FROM_HMODULE etc.)
|
||||
const DWORD lang_id = 0; // look for neutral, then current locale
|
||||
va_list* args = 0; // we don't care about "inserts"
|
||||
const DWORD chars_output = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, source, err, lang_id, buf, (DWORD)max_chars, args);
|
||||
if(!chars_output)
|
||||
WARN_RETURN(ERR::FAIL);
|
||||
debug_assert(chars_output < max_chars);
|
||||
char message[200];
|
||||
{
|
||||
const LPCVOID source = 0; // ignored (we're not using FROM_HMODULE etc.)
|
||||
const DWORD lang_id = 0; // look for neutral, then current locale
|
||||
va_list* args = 0; // we don't care about "inserts"
|
||||
const DWORD charsWritten = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, source, err, lang_id, message, (DWORD)ARRAY_SIZE(message), args);
|
||||
if(!charsWritten)
|
||||
WARN_RETURN(ERR::FAIL);
|
||||
debug_assert(charsWritten < max_chars);
|
||||
}
|
||||
|
||||
const int charsWritten = sprintf_s(buf, max_chars, "%d (%s)", err, message);
|
||||
debug_assert(charsWritten != -1);
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user