mirror of https://gitee.com/bigwinds/arangodb
Fix edge cache behaviour (#3079)
* fixing cache resizing bug * reenabling test
This commit is contained in:
parent
2bfcba3be5
commit
b76b53d87a
|
@ -245,7 +245,7 @@ void Cache::requestMigrate(uint32_t requestedLogSize) {
|
|||
(requestedLogSize != _table->logSize());
|
||||
_metadata.unlock();
|
||||
if (ok) {
|
||||
std::tie(ok, _resizeRequestTime) =
|
||||
std::tie(ok, _migrateRequestTime) =
|
||||
_manager->requestMigrate(shared_from_this(), requestedLogSize);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,11 +190,19 @@ arangodb::Result Indexes::getAll(arangodb::LogicalCollection const* collection,
|
|||
if (val.isNumber()) {
|
||||
selectivity += val.getNumber<double>();
|
||||
}
|
||||
|
||||
bool useCache = false;
|
||||
VPackSlice figures = index.get("figures");
|
||||
if (figures.isObject() && !figures.isEmptyObject()) {
|
||||
if ((val = figures.get("cacheInUse")).isBool()) {
|
||||
useCache = val.getBool();
|
||||
}
|
||||
if ((val = figures.get("memory")).isNumber()) {
|
||||
memory += val.getNumber<double>();
|
||||
}
|
||||
if ((val = figures.get("cacheSize")).isNumber()) {
|
||||
cacheSize += val.getNumber<double>();
|
||||
}
|
||||
if ((val = figures.get("cacheLifeTimeHitRate")).isNumber()) {
|
||||
cacheLifeTimeHitRate += val.getNumber<double>();
|
||||
}
|
||||
|
@ -215,7 +223,7 @@ arangodb::Result Indexes::getAll(arangodb::LogicalCollection const* collection,
|
|||
if (withFigures) {
|
||||
merge.add("figures", VPackValue(VPackValueType::Object));
|
||||
merge.add("memory", VPackValue(memory));
|
||||
if (cacheSize != 0 || cacheLifeTimeHitRate != 0) {
|
||||
if (useCache) {
|
||||
merge.add("cacheSize", VPackValue(cacheSize));
|
||||
merge.add("cacheLifeTimeHitRate",
|
||||
VPackValue(cacheLifeTimeHitRate / 2));
|
||||
|
|
|
@ -35,7 +35,6 @@ var testHelper = require("@arangodb/test-helper").Helper;
|
|||
var db = arangodb.db;
|
||||
var ERRORS = arangodb.errors;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test suite: collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -405,14 +404,14 @@ function CollectionSuite () {
|
|||
},
|
||||
|
||||
testEdgeCacheBehaviour : function() {
|
||||
return;
|
||||
|
||||
var cn = "UnitLoadBehaviour123";
|
||||
db._drop(cn);
|
||||
var c = db._createEdgeCollection(cn);
|
||||
c.load();
|
||||
for(i=0;i<10000;i++) {
|
||||
for(let i=0;i<10000;i++) {
|
||||
c.insert({_from:"c/v"+(i/100), _to:"c/v"+i});
|
||||
c.insert({_to:"c/v"+(i/100), _from:"c/v"+i});
|
||||
}
|
||||
|
||||
// check if edge cache is present
|
||||
|
@ -422,7 +421,7 @@ function CollectionSuite () {
|
|||
var inital = [];
|
||||
idxs.forEach(function(idx) {
|
||||
if (idx.figures.cacheInUse) {
|
||||
inital.push(idx.figures.cacheSize);
|
||||
inital.push(idx.figures);
|
||||
} else {
|
||||
inital.push(-1);
|
||||
}
|
||||
|
@ -432,23 +431,38 @@ function CollectionSuite () {
|
|||
|
||||
// checking if edge cach grew
|
||||
idxs = c.getIndexes(true);
|
||||
var i = 0;
|
||||
idxs.forEach(function(idx) {
|
||||
idxs.forEach(function(idx, i) {
|
||||
if (idx.figures.cacheInUse) {
|
||||
assertTrue(idx.figures.cacheSize > inital[i], idx);
|
||||
assertTrue(idx.figures.cacheSize > inital[i].cacheSize, idx);
|
||||
assertEqual(idx.figures.cacheLifeTimeHitRate, 0, idx);
|
||||
inital[i] = idx.figures;
|
||||
}
|
||||
i++;
|
||||
});
|
||||
|
||||
for(i=0;i<10000;i++) {
|
||||
for(let i=0;i<10000;i++) {
|
||||
c.outEdges("c/v"+(i/100));
|
||||
c.inEdges("c/v"+(i/100));
|
||||
}
|
||||
idxs = c.getIndexes(true);
|
||||
// cache was filled same queries, hit rate must be bigly
|
||||
idxs.forEach(function(idx) {
|
||||
// cache was filled same queries, hit rate must be about
|
||||
idxs.forEach(function(idx, i) {
|
||||
if (idx.figures.cacheInUse) {
|
||||
assertTrue(idx.figures.cacheLifeTimeHitRate > 0.9, idx);
|
||||
let diff = Math.abs(inital[i].cacheSize - idx.figures.cacheSize);
|
||||
assertTrue(diff <= Math.pow(2, 21), idx);
|
||||
assertTrue(idx.figures.cacheLifeTimeHitRate > 25, idx);
|
||||
inital[i] = idx.figures;
|
||||
}
|
||||
});
|
||||
for(let i=0;i<10000;i++) {
|
||||
c.outEdges("c/v"+(i/100));
|
||||
c.inEdges("c/v"+(i/100));
|
||||
}
|
||||
idxs = c.getIndexes(true);
|
||||
// cache was filled same queries, hit rate must be biglier
|
||||
idxs.forEach(function(idx, i) {
|
||||
if (idx.figures.cacheInUse) {
|
||||
assertTrue(Math.abs(inital[i].cacheSize - idx.figures.cacheSize) < 1024);
|
||||
assertTrue(idx.figures.cacheLifeTimeHitRate > 40, idx);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -460,8 +474,9 @@ function CollectionSuite () {
|
|||
});
|
||||
|
||||
// lets do some reads
|
||||
for(i=0;i<10000;i++) {
|
||||
for(let i=0;i<10000;i++) {
|
||||
c.outEdges("c/v"+(i/100));
|
||||
c.inEdges("c/v"+(i/100));
|
||||
}
|
||||
idxs = c.getIndexes(true);
|
||||
// cache was empty, hit rate should be 0
|
||||
|
@ -472,15 +487,16 @@ function CollectionSuite () {
|
|||
}
|
||||
});
|
||||
|
||||
for(i=0;i<10000;i++) {
|
||||
for(let i=0;i<10000;i++) {
|
||||
c.outEdges("c/v"+(i/100));
|
||||
c.inEdges("c/v"+(i/100));
|
||||
}
|
||||
idxs = c.getIndexes(true);
|
||||
// cache was partially filled same queries, lifetime hit rate
|
||||
// should be about 50 %
|
||||
idxs.forEach(function(idx) {
|
||||
if (idx.figures.cacheInUse) {
|
||||
assertTrue(idx.figures.cacheLifeTimeHitRate > 0.45, idx);
|
||||
assertTrue(idx.figures.cacheLifeTimeHitRate > 25, idx);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue