mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-11-15 10:20:47 +00:00
[HER-1609] wide crawl performance is limited by lock contention in ServerCache.getServerFor(String)
* (all, especially CachedBdbMap.java)
pbaclace-contributed patch, ported to H3, plus...
* StatisticsTracker.java
replace LongWrapper with AtomicLong
use non-recursive putIfAbsent-based idiom for get-or-create
* DefaultServerCache.java
clean up host/server get-or-create around non-recursive concurrent idiom
* BdbModule.java
add expectedConcurrency property & je.lock.nLockTables tuning
* TopNSet.java
add synchronization, as calling StatisticsTracker method has lost it
This commit is contained in:
1 parent
4583ff7306
commit
149fc414df
14 files changed
+1519
-395
No files matched your search
@@ -28,6 +28,7 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -37,6 +38,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -207,6 +209,19 @@ Serializable, Closeable {
|
||||
this.checkpointCopyLogs = checkpointCopyLogs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expected number of concurrent threads; used to tune nLockTables
|
||||
* according to JE FAQ
|
||||
* http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#33
|
||||
*/
|
||||
int expectedConcurrency = 25;
|
||||
public int getExpectedConcurrency() {
|
||||
return expectedConcurrency;
|
||||
}
|
||||
public void setExpectedConcurrency(int expectedConcurrency) {
|
||||
this.expectedConcurrency = expectedConcurrency;
|
||||
}
|
||||
|
||||
private transient EnhancedEnvironment bdbEnvironment;
|
||||
|
||||
private transient StoredClassCatalog classCatalog;
|
||||
@@ -256,6 +271,14 @@ Serializable, Closeable {
|
||||
config.setCachePercent(cachePercent);
|
||||
config.setSharedCache(sharedCache);
|
||||
|
||||
// we take the advice literally from...
|
||||
// http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#33
|
||||
long nLockTables = expectedConcurrency-1;
|
||||
while(!BigInteger.valueOf(nLockTables).isProbablePrime(Integer.MAX_VALUE)) {
|
||||
nLockTables--;
|
||||
}
|
||||
config.setConfigParam("je.lock.nLockTables", Long.toString(nLockTables));
|
||||
|
||||
f.mkdirs();
|
||||
this.bdbEnvironment = new EnhancedEnvironment(f, config);
|
||||
|
||||
@@ -329,7 +352,7 @@ Serializable, Closeable {
|
||||
}
|
||||
|
||||
|
||||
public <K,V> Map<K,V> getBigMap(String dbName, boolean recycle,
|
||||
public <K,V> ConcurrentMap<K,V> getBigMap(String dbName, boolean recycle,
|
||||
Class<? super K> key, Class<? super V> value)
|
||||
throws DatabaseException {
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -359,7 +382,7 @@ Serializable, Closeable {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO:FIXME: restore functionality
|
||||
@SuppressWarnings("unchecked")
|
||||
private void readObject(ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException {
|
||||
@@ -374,8 +397,10 @@ Serializable, Closeable {
|
||||
for (CachedBdbMap map: bigMaps.values()) {
|
||||
map.initialize(
|
||||
this.bdbEnvironment,
|
||||
map.getKeyClass(),
|
||||
map.getValueClass(),
|
||||
null,
|
||||
null,
|
||||
// map.getKeyClass(),
|
||||
// map.getValueClass(),
|
||||
this.classCatalog);
|
||||
}
|
||||
for (DatabasePlusConfig dpc: databases.values()) {
|
||||
|
||||
Reference in new issue
Block a user