From: Henrik Nordstrom Date: Tue, 4 Aug 2009 02:31:27 +0000 (+0200) Subject: finetune memory release logics on objects being swapped out X-Git-Tag: SQUID_3_2_0_1~795^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10aeba1dbd7e8814f7e6d0038db24692c42f0dc3;p=thirdparty%2Fsquid.git finetune memory release logics on objects being swapped out --- diff --git a/src/MemObject.cc b/src/MemObject.cc index 0c588056c2..815bf9bbee 100644 --- a/src/MemObject.cc +++ b/src/MemObject.cc @@ -313,7 +313,7 @@ MemObject::objectBytesOnDisk() const } int64_t -MemObject::policyLowestOffsetToKeep() const +MemObject::policyLowestOffsetToKeep(bool swap) const { /* * Careful. lowest_offset can be greater than endOffset(), such @@ -323,7 +323,7 @@ MemObject::policyLowestOffsetToKeep() const if (endOffset() < lowest_offset || endOffset() - inmem_lo > (int64_t)Config.Store.maxInMemObjSize || - !Config.onoff.memory_cache_first) + (swap && !Config.onoff.memory_cache_first)) return lowest_offset; return inmem_lo; @@ -332,7 +332,7 @@ MemObject::policyLowestOffsetToKeep() const void MemObject::trimSwappable() { - int64_t new_mem_lo = policyLowestOffsetToKeep(); + int64_t new_mem_lo = policyLowestOffsetToKeep(1); /* * We should only free up to what we know has been written * to disk, not what has been queued for writing. Otherwise @@ -357,7 +357,7 @@ MemObject::trimSwappable() void MemObject::trimUnSwappable() { - int64_t new_mem_lo = policyLowestOffsetToKeep(); + int64_t new_mem_lo = policyLowestOffsetToKeep(0); assert (new_mem_lo > 0); data_hdr.freeDataUpto(new_mem_lo); diff --git a/src/MemObject.h b/src/MemObject.h index 5464ccb197..3631db6d56 100644 --- a/src/MemObject.h +++ b/src/MemObject.h @@ -73,7 +73,7 @@ public: * better */ int64_t objectBytesOnDisk() const; - int64_t policyLowestOffsetToKeep() const; + int64_t policyLowestOffsetToKeep(bool swap) const; void trimSwappable(); void trimUnSwappable(); bool isContiguous() const; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 188a115ad3..19dd089d92 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -2784,16 +2784,16 @@ parse_memcachemode(SquidConfig * config) if (!token) self_destruct(); - if (strcmp(token, "always")) { + if (strcmp(token, "always") == 0) { Config.onoff.memory_cache_first = 1; Config.onoff.memory_cache_disk = 1; - } else if (strcmp(token, "disk")) { + } else if (strcmp(token, "disk") == 0) { Config.onoff.memory_cache_first = 0; Config.onoff.memory_cache_disk = 1; } else if (strncmp(token, "net", 3) == 0) { Config.onoff.memory_cache_first = 1; Config.onoff.memory_cache_disk = 0; - } else if (strncmp(token, "none", 3) == 0) { + } else if (strcmp(token, "never") == 0) { Config.onoff.memory_cache_first = 0; Config.onoff.memory_cache_disk = 0; } else diff --git a/src/store.cc b/src/store.cc index 2be8cc5360..29c097384a 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1839,11 +1839,11 @@ StoreEntry::trimMemory() if (mem_status == IN_MEMORY) return; - if (mem_obj->policyLowestOffsetToKeep() == 0) - /* Nothing to do */ - return; - if (!swapOutAble()) { + if (mem_obj->policyLowestOffsetToKeep(0) == 0) { + /* Nothing to do */ + return; + } /* * Its not swap-able, and we're about to delete a chunk, * so we must make it PRIVATE. This is tricky/ugly because