зеркало из https://github.com/mozilla/pjs.git
Bug 592422 - preallocate individual (non-block) cache files. r=jduell,taras a=b
This commit is contained in:
Родитель
7cdec4ea1e
Коммит
193d18fb5f
|
@ -94,6 +94,9 @@ struct nsDiskCacheEntry;
|
|||
#define kMaxDataFileSize 5 * 1024 * 1024 // 5 MB (in bytes)
|
||||
#define kBuckets (1 << 5) // must be a power of 2!
|
||||
|
||||
// preallocate up to 1MB of separate cache file
|
||||
#define kPreallocateLimit 1 * 1024 * 1024
|
||||
|
||||
class nsDiskCacheRecord {
|
||||
|
||||
private:
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsDiskCacheDevice.h"
|
||||
#include "nsDiskCacheStreams.h"
|
||||
#include "nsCacheService.h"
|
||||
#include "mozilla/FileUtils.h"
|
||||
|
||||
|
||||
|
||||
|
@ -728,6 +729,10 @@ nsDiskCacheStreamIO::FlushBufferToFile()
|
|||
// allocate file
|
||||
rv = OpenCacheFile(PR_RDWR | PR_CREATE_FILE, &mFD);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt64 dataSize = mBinding->mCacheEntry->PredictedDataSize();
|
||||
if (dataSize != -1)
|
||||
mozilla::fallocate(mFD, PR_MIN(dataSize, kPreallocateLimit));
|
||||
}
|
||||
|
||||
// write buffer
|
||||
|
|
|
@ -47,10 +47,12 @@
|
|||
#include "nscore.h"
|
||||
#include "private/pprio.h"
|
||||
#include "mozilla/FileUtils.h"
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
|
||||
bool
|
||||
mozilla::fallocate(PRFileDesc *aFD, PRInt64 aLength)
|
||||
{
|
||||
NS_TIME_FUNCTION;
|
||||
#if defined(HAVE_POSIX_FALLOCATE)
|
||||
return posix_fallocate(PR_FileDesc2NativeHandle(aFD), 0, aLength) == 0;
|
||||
#elif defined(XP_WIN)
|
||||
|
|
Загрузка…
Ссылка в новой задаче