зеркало из https://github.com/mozilla/pjs.git
Bug 661351 - Clean up code that worked around bad values from PR_GetPhysicalMemorySize [r=mak]
This commit is contained in:
Родитель
58c16d1510
Коммит
c00b6f2a0a
|
@ -135,11 +135,8 @@ using namespace mozilla::places;
|
|||
// Out of this cache, SQLite will use at most the size of the database file.
|
||||
#define DATABASE_DEFAULT_CACHE_TO_MEMORY_PERCENTAGE 6
|
||||
|
||||
// PR_GetPhysicalMemorySize sometimes returns garbage (bug 660036). If the
|
||||
// return value is greater than MEMSIZE_MAX_BYTES, assume it is garbage and
|
||||
// use MEMSIZE_FALLBACK_BYTES instead. Must stay in sync with the code in
|
||||
// nsPlacesExpiration.js.
|
||||
#define MEMSIZE_MAX_BYTES 137438953472LL // 128 G
|
||||
// If the physical memory size is not available, use MEMSIZE_FALLBACK_BYTES
|
||||
// instead. Must stay in sync with the code in nsPlacesExpiration.js.
|
||||
#define MEMSIZE_FALLBACK_BYTES 268435456 // 256 M
|
||||
|
||||
// Maximum size for the WAL file. It should be small enough since in case of
|
||||
|
@ -733,14 +730,14 @@ nsNavHistory::InitDB()
|
|||
if (cachePercentage < 0)
|
||||
cachePercentage = 0;
|
||||
|
||||
static PRInt64 physMem = PR_GetPhysicalMemorySize();
|
||||
if (physMem <= 0 || physMem > MEMSIZE_MAX_BYTES)
|
||||
static PRUint64 physMem = PR_GetPhysicalMemorySize();
|
||||
if (physMem == 0)
|
||||
physMem = MEMSIZE_FALLBACK_BYTES;
|
||||
|
||||
PRInt64 cacheSize = physMem * cachePercentage / 100;
|
||||
PRUint64 cacheSize = physMem * cachePercentage / 100;
|
||||
|
||||
// Compute number of cached pages, this will be our cache size.
|
||||
PRInt64 cachePages = cacheSize / mDBPageSize;
|
||||
PRUint64 cachePages = cacheSize / mDBPageSize;
|
||||
nsCAutoString cacheSizePragma("PRAGMA cache_size = ");
|
||||
cacheSizePragma.AppendInt(cachePages);
|
||||
rv = mDBConn->ExecuteSimpleSQL(cacheSizePragma);
|
||||
|
|
|
@ -717,17 +717,14 @@ nsPlacesExpiration.prototype = {
|
|||
catch(e) {}
|
||||
|
||||
if (this._urisLimit < 0) {
|
||||
// PR_GetPhysicalMemorySize sometimes returns garbage (bug 660036).
|
||||
// If the return value is greater than MEMSIZE_MAX_BYTES, assume it is
|
||||
// garbage and use MEMSIZE_FALLBACK_BYTES instead. Must stay in sync
|
||||
// with the code in nsNavHistory.cpp.
|
||||
const MEMSIZE_MAX_BYTES = 137438953472; // 128 G
|
||||
// If physical memory size is not available, use MEMSIZE_FALLBACK_BYTES
|
||||
// instead. Must stay in sync with the code in nsNavHistory.cpp.
|
||||
const MEMSIZE_FALLBACK_BYTES = 268435456; // 256 M
|
||||
|
||||
// The preference did not exist or has a negative value, so we calculate a
|
||||
// limit based on hardware.
|
||||
let memsize = this._sys.getProperty("memsize"); // Memory size in bytes.
|
||||
if (memsize <= 0 || memsize > MEMSIZE_MAX_BYTES)
|
||||
if (memsize <= 0)
|
||||
memsize = MEMSIZE_FALLBACK_BYTES;
|
||||
|
||||
let cpucount = this._sys.getProperty("cpucount"); // CPU count.
|
||||
|
|
Загрузка…
Ссылка в новой задаче