I have a task with a lot of lookups. They usually goes quite near in terms of keys.
The effect is I can not get more than about 5-6 cores working effectivly.
Other threads gets locked in the last line of code below (StoreDirectAbstract, lines 37+):
//TODO PERF indexPages are synchronized writes are protected by structural lock, but should it be read under locks?
protected val indexPages = if(isThreadSafe) LongArrayList().asSynchronized() else LongArrayList()
protected fun recidToOffset(recid2:Long):Long{
var recid = recid2-1; //normalize recid so it starts from zero
if(recid< StoreDirectJava.RECIDS_PER_ZERO_INDEX_PAGE){
//zero index page
return StoreDirectJava.HEAD_END + 16 + recid*8
}
//strip zero index page
recid -= StoreDirectJava.RECIDS_PER_ZERO_INDEX_PAGE
val pageNum = recid/ StoreDirectJava.RECIDS_PER_INDEX_PAGE
return indexPages.get(pageNum.toInt()) + 16 + ((recid)% StoreDirectJava.RECIDS_PER_INDEX_PAGE)*8
}
seems that indexPages.get(pageNum.toInt()) causes the problem, as this call is synchronized.
below actual implementation of get (from eclipse collections):
public long get(int index)
{
synchronized (this.getLock())
{
return this.getMutableLongList().get(index);
}
}
I have a task with a lot of lookups. They usually goes quite near in terms of keys.
The effect is I can not get more than about 5-6 cores working effectivly.
Other threads gets locked in the last line of code below (StoreDirectAbstract, lines 37+):
seems that indexPages.get(pageNum.toInt()) causes the problem, as this call is synchronized.
below actual implementation of get (from eclipse collections):