Hi all.
I am using GenericBooleanPrefItemBasedRecommender with Tanimoto similarity.
To improve performance I used CachingUserSimilarity (code below)
public Recommender buildRecommender(DataModel dataModel) throws TasteException {
UserSimilarity similarity = new CachingUserSimilarity(new
TanimotoCoefficientSimilarity(similarityDataModel), similarityDataModel);
UserNeighborhood neighborhood = new NearestNUserNeighborhood(8,
Double.NEGATIVE_INFINITY, similarity, dataModel, 1.0);
return new GenericBooleanPrefUserBasedRecommender(dataModel,
neighborhood, similarity);
}
However when I ran load tests on my server then I found that only about two out
of eight cpu cores were utilized. The rest was waiting idle in
org.apache.mahout.cf.taste.impl.common.Cache.get method. That is probably due
to the fact that Cache.get method used in CachingUserSimilarity looks like this:
public V get(K key) throws TasteException {
V value;
synchronized (cache) {
value = cache.get(key);
}
...
Threads doing concurrent reads are blocking each other. I would expect standard
double-checked locking pattern there to avoid that if it is not necessary (i.e.
there is a hit and the cache is not modified).
Am I doing something wrong or there is a defect in Cache class?
--
Pozdrowienia,
Tomasz Tretkowski