Bug 411579 - "Optimize read file buffer sizes for faster startup times" [p=jmathies@mozilla.com (Jim Mathies) r=sayrer sr=bsmedberg a=blocking1.9+]

This commit is contained in:
reed@reedloden.com 2008-01-29 12:51:46 -08:00
Родитель 892f0acecf
Коммит 17dee2a4d9
3 изменённых файлов: 28 добавлений и 18 удалений

Просмотреть файл

@ -99,13 +99,13 @@ static const char kObserverServiceContractID[] = "@mozilla.org/observer-service;
/**
* Buffer sizes for serialization and deserialization of scripts.
* These should be tuned at some point.
* FIXME: bug #411579 (tune this macro!) Last updated: Jan 2008
*/
#define XPC_SERIALIZATION_BUFFER_SIZE (64 * 1024)
#define XPC_DESERIALIZATION_BUFFER_SIZE (8 * 1024)
#define XPC_DESERIALIZATION_BUFFER_SIZE (12 * 8192)
// Inactivity delay before closing our fastload file stream.
static const int kFastLoadWriteDelay = 5000; // 5 seconds
static const int kFastLoadWriteDelay = 10000; // 10 seconds
#ifdef PR_LOGGING
// NSPR_LOG_MODULES=JSComponentLoader:5

Просмотреть файл

@ -68,7 +68,6 @@
// Definitions
#define INITIAL_PREF_FILES 10
#define PREF_READ_BUFFER_SIZE 4096
// Prototypes
#ifdef MOZ_PROFILESHARING
@ -586,7 +585,6 @@ static PRBool isSharingEnabled()
static nsresult openPrefFile(nsIFile* aFile)
{
nsCOMPtr<nsIInputStream> inStr;
char readBuf[PREF_READ_BUFFER_SIZE];
#if MOZ_TIMELINE
{
@ -600,21 +598,33 @@ static nsresult openPrefFile(nsIFile* aFile)
if (NS_FAILED(rv))
return rv;
PRInt64 fileSize;
rv = aFile->GetFileSize(&fileSize);
if (NS_FAILED(rv))
return rv;
char *fileBuffer = nsnull;
fileBuffer = new char[fileSize];
if (fileBuffer == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
PRUint32 amtRead = 0;
rv = inStr->Read(fileBuffer, fileSize, &amtRead);
if (NS_FAILED(rv)) {
delete fileBuffer;
return rv;
}
PrefParseState ps;
PREF_InitParseState(&ps, PREF_ReaderCallback, NULL);
nsresult rv2 = NS_OK;
for (;;) {
PRUint32 amtRead = 0;
rv = inStr->Read(readBuf, sizeof(readBuf), &amtRead);
if (NS_FAILED(rv) || amtRead == 0)
break;
if (!PREF_ParseBuf(&ps, readBuf, amtRead)) {
rv2 = NS_ERROR_FILE_CORRUPTED;
}
}
if (!PREF_ParseBuf(&ps, fileBuffer, amtRead))
rv = NS_ERROR_FILE_CORRUPTED;
PREF_FinalizeParseState(&ps);
return NS_FAILED(rv) ? rv : rv2;
delete fileBuffer;
return rv;
}
/*

Просмотреть файл

@ -630,9 +630,9 @@ nsFastLoadFileReader::SetInputStream(nsIInputStream *aInputStream)
}
/**
* XXX tuneme
* FIXME: bug #411579 (tune this macro!) Last updated: Jan 2008
*/
#define MFL_CHECKSUM_BUFSIZE 8192
#define MFL_CHECKSUM_BUFSIZE (6 * 8192)
NS_IMETHODIMP
nsFastLoadFileReader::ComputeChecksum(PRUint32 *aResult)