Remove 2nd level cache

This commit is contained in:
Dávid Szabó 2016-08-24 23:09:36 +02:00 committed by Julian Descottes
parent 6ee23e22df
commit 0bbb4ff2d5
2 changed files with 17 additions and 11 deletions

View file

@ -32,18 +32,19 @@
processedFrame = cache[key1];
} else if (frame instanceof pskl.model.frame.RenderedFrame) {
// Cannot use 2nd level cache with rendered frames
var callbackFirstLvlCacheOnly = this.onProcessorComplete_.bind(this, deferred, cache, key1, key1);
var callbackFirstLvlCacheOnly = this.onProcessorComplete_.bind(this, deferred, cache, key1/*, key1*/);
this.frameProcessor(frame, callbackFirstLvlCacheOnly);
} else {
var framePixels = JSON.stringify(frame.getPixels());
// TODO: Remove?
/*var framePixels = new Float64Array(frame.pixels.buffer).toString();
var key2 = pskl.utils.hashCode(framePixels);
if (cache[key2]) {
processedFrame = this.outputCloner(cache[key2], frame);
cache[key1] = processedFrame;
} else {
var callback = this.onProcessorComplete_.bind(this, deferred, cache, key1, key2);
this.frameProcessor(frame, callback);
}
} else {*/
var callback = this.onProcessorComplete_.bind(this, deferred, cache, key1/*, key1*/);
this.frameProcessor(frame, callback);/*
}*/
}
if (processedFrame) {
@ -53,9 +54,9 @@
return deferred.promise;
};
ns.AsyncCachedFrameProcessor.prototype.onProcessorComplete_ = function (deferred, cache, key1, key2, result) {
ns.AsyncCachedFrameProcessor.prototype.onProcessorComplete_ = function (deferred, cache, key1/*, key2*/, result) {
cache[key1] = result;
cache[key2] = result;
//cache[key2] = result;
deferred.resolve(result);
};
})();

View file

@ -71,16 +71,21 @@
processedFrame = this.frameProcessor(frame);
cache[cacheKey] = processedFrame;
} else {
var framePixels = JSON.stringify(frame.getPixels());
// TODO: Remove?
/*
// Float64Array.toString() is about 2.4x times faster compared to Uint32Array.toString()
var framePixels = new Float64Array(frame.pixels.buffer).toString();
var frameAsString = pskl.utils.hashCode(framePixels);
if (cache[frameAsString]) {
this.cacheHitLvl2_++;
processedFrame = this.outputCloner(cache[frameAsString], frame);
} else {
processedFrame = this.frameProcessor(frame);
*/processedFrame = this.frameProcessor(frame);/*
cache[frameAsString] = processedFrame;
}
cache[cacheKey] = processedFrame;
cache[cacheKey] = processedFrame;*/
}
return processedFrame;
};
})();