Comparing version 0.0.46 to 0.0.47
@@ -1,2 +0,2 @@ | ||
/*! dw-cache v0.0.46 https://github.com/falsandtru/dw-cache | (c) 2021, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
/*! dw-cache v0.0.47 https://github.com/falsandtru/dw-cache | (c) 2021, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
@@ -464,4 +464,5 @@ if(typeof exports === 'object' && typeof module === 'object') | ||
if (this.sweep > 0) { | ||
LRU.head = this.misses === LRU.length + 1 ? LRU.head.next : LRU.head.next.next; | ||
this.sweep === 1 ? this.sweep = -LRU.length * this.settings.sweep / 100 | 0 : --this.sweep; | ||
this.sweep === 1 ? LRU.head = LRU.head.next : LRU.head = LRU.head.next.next; | ||
--this.sweep; | ||
this.sweep ||= -LRU.length * this.settings.sweep / 100 | 0; | ||
} else { | ||
@@ -548,6 +549,6 @@ this.sweep === -1 ? LRU.head = LRU.head.next : void 0; | ||
this.misses &&= 0; | ||
const expiry = node.value.expiry; | ||
if (expiry !== global_1.Infinity && expiry < (0, clock_1.now)()) { | ||
++this.misses; | ||
this.evict(node, true); | ||
@@ -561,2 +562,4 @@ return; | ||
this.adjust(); | ||
this.misses &&= 0; | ||
this.sweep = 0; | ||
return node.value.value; | ||
@@ -588,2 +591,4 @@ } | ||
clear() { | ||
this.misses = 0; | ||
this.sweep = 0; | ||
this.overlap = 0; | ||
@@ -590,0 +595,0 @@ this.SIZE = 0; |
@@ -7,3 +7,3 @@ module.exports = function (config) { | ||
{ pattern: 'dist/**/*.{js,map}', watched: true, served: true, included: true }, | ||
{ pattern: 'benchmark/*', watched: false, served: true, included: false }, | ||
{ pattern: 'benchmark/trace/*', watched: false, served: true, included: false }, | ||
], | ||
@@ -10,0 +10,0 @@ reporters: ['dots'], |
{ | ||
"name": "dw-cache", | ||
"version": "0.0.46", | ||
"version": "0.0.47", | ||
"description": "Dual window cache adaptively coordinates the ratio of LRU to LFU using the two sliding windows.", | ||
@@ -52,4 +52,4 @@ "private": false, | ||
"mocha": "^10.0.0", | ||
"npm-check-updates": "^16.0.1", | ||
"spica": "0.0.588", | ||
"npm-check-updates": "^16.0.3", | ||
"spica": "0.0.589", | ||
"ts-loader": "^9.3.1", | ||
@@ -56,0 +56,0 @@ "typescript": "4.7.4", |
108
README.md
@@ -13,12 +13,12 @@ # Dual Window Cache | ||
## Extra keys | ||
## Efficiency and Resistance | ||
Some cache algorithms require extra memory space to retain evicted keys. | ||
Some different cache algorithms require extra memory space to retain evicted keys. | ||
|Algorithm|Key size|Lists| | ||
|:-------:|:------:|:---:| | ||
| LRU | x1 | 1 | | ||
| DWC | x1 | 2 | | ||
| ARC | x2 | 4 | | ||
| LIRS | x3 | 2 | | ||
|Algorithm|Key size|Lists|Scan resistance|Loop resistance| | ||
|:-------:|:------:|:---:|:-------------:|:-------------:| | ||
| LRU | x1 | 1 | - | - | | ||
| DWC | x1 | 2 | O | O | | ||
| ARC | x2 | 4 | O | - | | ||
| LIRS | x3 | 2 | O | O | | ||
@@ -58,5 +58,5 @@ https://github.com/ben-manes/caffeine/wiki/Efficiency | ||
LRU hit rate 16.4% | ||
DWC hit rate 18.3% | ||
DWC - LRU hit rate delta 1.8% | ||
DWC / LRU hit rate ratio 111% | ||
DWC hit rate 18.4% | ||
DWC - LRU hit rate delta 2.0% | ||
DWC / LRU hit rate ratio 112% | ||
@@ -66,3 +66,3 @@ OLTP 500 | ||
DWC hit rate 28.9% | ||
DWC - LRU hit rate delta 5.4% | ||
DWC - LRU hit rate delta 5.5% | ||
DWC / LRU hit rate ratio 123% | ||
@@ -72,3 +72,3 @@ | ||
LRU hit rate 28.2% | ||
DWC hit rate 34.6% | ||
DWC hit rate 34.7% | ||
DWC - LRU hit rate delta 6.4% | ||
@@ -80,3 +80,3 @@ DWC / LRU hit rate ratio 122% | ||
DWC hit rate 38.0% | ||
DWC - LRU hit rate delta 5.2% | ||
DWC - LRU hit rate delta 5.1% | ||
DWC / LRU hit rate ratio 115% | ||
@@ -96,29 +96,29 @@ | ||
LRU hit rate 0.9% | ||
DWC hit rate 10.7% | ||
DWC - LRU hit rate delta 9.8% | ||
DWC / LRU hit rate ratio 1157% | ||
DWC hit rate 11.8% | ||
DWC - LRU hit rate delta 10.9% | ||
DWC / LRU hit rate ratio 1276% | ||
GLI 500 | ||
LRU hit rate 0.9% | ||
DWC hit rate 23.0% | ||
DWC - LRU hit rate delta 22.0% | ||
DWC / LRU hit rate ratio 2386% | ||
DWC hit rate 23.4% | ||
DWC - LRU hit rate delta 22.4% | ||
DWC / LRU hit rate ratio 2429% | ||
GLI 750 | ||
LRU hit rate 1.1% | ||
DWC hit rate 38.1% | ||
DWC - LRU hit rate delta 37.0% | ||
DWC / LRU hit rate ratio 3279% | ||
DWC hit rate 38.0% | ||
DWC - LRU hit rate delta 36.8% | ||
DWC / LRU hit rate ratio 3267% | ||
GLI 1,000 | ||
LRU hit rate 11.2% | ||
DWC hit rate 46.9% | ||
DWC - LRU hit rate delta 35.6% | ||
DWC / LRU hit rate ratio 418% | ||
DWC hit rate 45.2% | ||
DWC - LRU hit rate delta 34.0% | ||
DWC / LRU hit rate ratio 403% | ||
GLI 1,250 | ||
LRU hit rate 21.2% | ||
DWC hit rate 47.6% | ||
DWC - LRU hit rate delta 26.3% | ||
DWC / LRU hit rate ratio 224% | ||
DWC hit rate 48.6% | ||
DWC - LRU hit rate delta 27.4% | ||
DWC / LRU hit rate ratio 228% | ||
@@ -133,5 +133,5 @@ GLI 1,500 | ||
LRU hit rate 45.0% | ||
DWC hit rate 54.1% | ||
DWC - LRU hit rate delta 9.1% | ||
DWC / LRU hit rate ratio 120% | ||
DWC hit rate 54.7% | ||
DWC - LRU hit rate delta 9.7% | ||
DWC / LRU hit rate ratio 121% | ||
@@ -141,3 +141,3 @@ GLI 2,000 | ||
DWC hit rate 57.4% | ||
DWC - LRU hit rate delta 0 | ||
DWC - LRU hit rate delta 0.0% | ||
DWC / LRU hit rate ratio 100% | ||
@@ -148,30 +148,30 @@ ``` | ||
LOOP 100 | ||
LRU hit rate 0% | ||
DWC hit rate 5.1% | ||
DWC - LRU hit rate delta 5.1% | ||
DWC / LRU hit rate ratio Infinity | ||
LRU hit rate 0.0% | ||
DWC hit rate 7.7% | ||
DWC - LRU hit rate delta 7.7% | ||
DWC / LRU hit rate ratio Infinity% | ||
LOOP 250 | ||
LRU hit rate 0% | ||
DWC hit rate 19.7% | ||
DWC - LRU hit rate delta 19.7% | ||
DWC / LRU hit rate ratio Infinity | ||
LRU hit rate 0.0% | ||
DWC hit rate 20.2% | ||
DWC - LRU hit rate delta 20.2% | ||
DWC / LRU hit rate ratio Infinity% | ||
LOOP 500 | ||
LRU hit rate 0% | ||
DWC hit rate 46.4% | ||
DWC - LRU hit rate delta 46.4% | ||
DWC / LRU hit rate ratio Infinity | ||
LRU hit rate 0.0% | ||
DWC hit rate 45.7% | ||
DWC - LRU hit rate delta 45.7% | ||
DWC / LRU hit rate ratio Infinity% | ||
LOOP 750 | ||
LRU hit rate 0% | ||
DWC hit rate 70.3% | ||
DWC - LRU hit rate delta 70.3% | ||
DWC / LRU hit rate ratio Infinity | ||
LRU hit rate 0.0% | ||
DWC hit rate 46.0% | ||
DWC - LRU hit rate delta 46.0% | ||
DWC / LRU hit rate ratio Infinity% | ||
LOOP 1,000 | ||
LRU hit rate 0% | ||
DWC hit rate 95.1% | ||
DWC - LRU hit rate delta 95.1% | ||
DWC / LRU hit rate ratio Infinity | ||
LRU hit rate 0.0% | ||
DWC hit rate 94.6% | ||
DWC - LRU hit rate delta 94.6% | ||
DWC / LRU hit rate ratio Infinity% | ||
@@ -181,3 +181,3 @@ LOOP 1,250 | ||
DWC hit rate 99.8% | ||
DWC - LRU hit rate delta 0% | ||
DWC - LRU hit rate delta 0.0% | ||
DWC / LRU hit rate ratio 100% | ||
@@ -184,0 +184,0 @@ ``` |
76495
1289