Changeset 70732 in webkit


Ignore:
Timestamp:
Oct 27, 2010 5:42:35 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2010-10-27 Pratik Solanki <psolanki@apple.com>

Reviewed by Darin Adler.

Improve memSize calculation in [WebView _setCacheModel]
https://bugs.webkit.org/show_bug.cgi?id=48484

  • WebView/WebView.mm: (roundUpToPowerOf2): Added. Utility function to calculate the nearest power of 2. (+[WebView _setCacheModel:]): Update memSize calculation to set it to the next bigger power of 2. Also update WebCore cache settings.
Location:
trunk/WebKit/mac
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/mac/ChangeLog

    r70723 r70732  
     12010-10-27  Pratik Solanki  <psolanki@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Improve memSize calculation in [WebView _setCacheModel]
     6        https://bugs.webkit.org/show_bug.cgi?id=48484
     7
     8        * WebView/WebView.mm:
     9        (roundUpToPowerOf2): Added. Utility function to calculate the nearest power of 2.
     10        (+[WebView _setCacheModel:]): Update memSize calculation to set it to the next
     11        bigger power of 2. Also update WebCore cache settings.
     12
    1132010-10-26  Darin Adler  <darin@apple.com>
    214
  • trunk/WebKit/mac/WebView/WebView.mm

    r70723 r70732  
    53095309@implementation WebView (WebFileInternal)
    53105310
     5311static inline uint64_t roundUpToPowerOf2(uint64_t num)
     5312{
     5313    return powf(2.0, ceilf(log2f(num)));
     5314}
     5315
    53115316+ (void)_setCacheModel:(WebCacheModel)cacheModel
    53125317{
     
    53185323        nsurlCacheDirectory = NSHomeDirectory();
    53195324
    5320     // As a fudge factor, use 1000 instead of 1024, in case the reported byte
    5321     // count doesn't align exactly to a megabyte boundary.
    5322     uint64_t memSize = WebMemorySize() / 1024 / 1000;
     5325    static uint64_t memSize = roundUpToPowerOf2(WebMemorySize() / 1024 / 1024);
    53235326    unsigned long long diskFreeSize = WebVolumeFreeSize(nsurlCacheDirectory) / 1024 / 1000;
    53245327    NSURLCache *nsurlCache = [NSURLCache sharedURLCache];
     
    53405343
    53415344        // Object cache capacities (in bytes)
    5342         if (memSize >= 2048)
     5345        if (memSize >= 4096)
     5346            cacheTotalCapacity = 128 * 1024 * 1024;
     5347        else if (memSize >= 2048)
    53435348            cacheTotalCapacity = 96 * 1024 * 1024;
    5344         else if (memSize >= 1536)
    5345             cacheTotalCapacity = 64 * 1024 * 1024;
    53465349        else if (memSize >= 1024)
    53475350            cacheTotalCapacity = 32 * 1024 * 1024;
     
    53725375
    53735376        // Object cache capacities (in bytes)
    5374         if (memSize >= 2048)
     5377        if (memSize >= 4096)
     5378            cacheTotalCapacity = 128 * 1024 * 1024;
     5379        else if (memSize >= 2048)
    53755380            cacheTotalCapacity = 96 * 1024 * 1024;
    5376         else if (memSize >= 1536)
    5377             cacheTotalCapacity = 64 * 1024 * 1024;
    53785381        else if (memSize >= 1024)
    53795382            cacheTotalCapacity = 32 * 1024 * 1024;
     
    54245427        // browsing pattern. Even growth above 128MB can have substantial
    54255428        // value / MB for some content / browsing patterns.)
    5426         if (memSize >= 2048)
     5429        if (memSize >= 4096)
     5430            cacheTotalCapacity = 192 * 1024 * 1024;
     5431        else if (memSize >= 2048)
    54275432            cacheTotalCapacity = 128 * 1024 * 1024;
    5428         else if (memSize >= 1536)
    5429             cacheTotalCapacity = 96 * 1024 * 1024;
    54305433        else if (memSize >= 1024)
    54315434            cacheTotalCapacity = 64 * 1024 * 1024;
Note: See TracChangeset for help on using the changeset viewer.