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

git-svn-id: svn://10.0.0.236/trunk@248995 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
reed%reedloden.com 2008-04-02 06:41:23 +00:00
parent f1f1f09ece
commit 5ff10fc2dd
3 changed files with 23 additions and 12 deletions

View File

@ -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

View File

@ -50,6 +50,7 @@
#include "nsCRT.h"
#include "nsCOMArray.h"
#include "nsXPCOMCID.h"
#include "nsAutoPtr.h"
#include "nsQuickSort.h"
#include "prmem.h"
@ -68,7 +69,6 @@
// Definitions
#define INITIAL_PREF_FILES 10
#define PREF_READ_BUFFER_SIZE 4096
// Prototypes
#ifdef MOZ_PROFILESHARING
@ -586,7 +586,6 @@ static PRBool isSharingEnabled()
static nsresult openPrefFile(nsIFile* aFile)
{
nsCOMPtr<nsIInputStream> inStr;
char readBuf[PREF_READ_BUFFER_SIZE];
#if MOZ_TIMELINE
{
@ -600,21 +599,33 @@ static nsresult openPrefFile(nsIFile* aFile)
if (NS_FAILED(rv))
return rv;
PRInt64 fileSize;
rv = aFile->GetFileSize(&fileSize);
if (NS_FAILED(rv))
return rv;
nsAutoArrayPtr<char> fileBuffer(new char[fileSize]);
if (fileBuffer == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
PrefParseState ps;
PREF_InitParseState(&ps, PREF_ReaderCallback, NULL);
// Read is not guaranteed to return a buf the size of fileSize,
// but usually will.
nsresult rv2 = NS_OK;
for (;;) {
PRUint32 amtRead = 0;
rv = inStr->Read(readBuf, sizeof(readBuf), &amtRead);
rv = inStr->Read((char*)fileBuffer, fileSize, &amtRead);
if (NS_FAILED(rv) || amtRead == 0)
break;
if (!PREF_ParseBuf(&ps, readBuf, amtRead)) {
if (!PREF_ParseBuf(&ps, fileBuffer, amtRead))
rv2 = NS_ERROR_FILE_CORRUPTED;
}
}
PREF_FinalizeParseState(&ps);
return NS_FAILED(rv) ? rv : rv2;
return NS_FAILED(rv) ? rv : rv2;
}
/*

View File

@ -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)