Modules TSC: Improve inter-thread synchronization.

More work to do with server.unixtime and similar. Need to write Helgrind
suppression file in order to suppress the valse positives.
This commit is contained in:
antirez
2017-05-09 11:57:09 +02:00
parent 2a51bac44e
commit ece658713b
5 changed files with 75 additions and 20 deletions

View File

@ -32,6 +32,7 @@
#include "server.h"
#include "bio.h"
#include "atomicvar.h"
/* ----------------------------------------------------------------------------
* Data structures
@ -72,6 +73,20 @@ unsigned int getLRUClock(void) {
return (mstime()/LRU_CLOCK_RESOLUTION) & LRU_CLOCK_MAX;
}
/* This function is used to obtain the current LRU clock.
* If the current resolution is lower than the frequency we refresh the
* LRU clock (as it should be in production servers) we return the
* precomputed value, otherwise we need to resort to a system call. */
unsigned int LRU_CLOCK(void) {
unsigned int lruclock;
if (1000/server.hz <= LRU_CLOCK_RESOLUTION) {
atomicGet(server.lruclock,lruclock);
} else {
lruclock = getLRUClock();
}
return lruclock;
}
/* Given an object returns the min number of milliseconds the object was never
* requested, using an approximated LRU algorithm. */
unsigned long long estimateObjectIdleTime(robj *o) {