performance hacks:

- faster generation of index abstract compression during remote search
- less synchronization in IO record reading
- request index abstract generation only if necessary and faster time-out in remote search 

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7239 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 6a166c2040
commit 24f1cba7b2

@ -171,7 +171,7 @@ public final class search {
sb.intermissionAllThreads(100);
EventTracker.delete(EventTracker.EClass.SEARCH);
final HandleSet abstractSet = ((abstracts.length() == 0) || (abstracts.equals("auto"))) ? null : QueryParams.hashes2Set(abstracts);
final HandleSet abstractSet = (abstracts.length() == 0 || abstracts.equals("auto")) ? null : QueryParams.hashes2Set(abstracts);
// store accessing peer
final yacySeed remoteSeed = yacySeed.genRemoteSeed(oseed, key, false);
@ -283,10 +283,15 @@ public final class search {
yacyChannel.channels(yacyChannel.REMOTESEARCH).addMessage(new RSSMessage("Remote Search Request from " + ((remoteSeed == null) ? "unknown" : remoteSeed.getName()), QueryParams.anonymizedQueryHashes(theQuery.queryHashes), ""));
// make event
theSearch = SearchEventCache.getEvent(theQuery, sb.peers, sb.crawlResults, null, true, sb.loader);
theSearch = SearchEventCache.getEvent(theQuery, sb.peers, sb.crawlResults, null, abstracts.length() > 0, sb.loader);
// set statistic details of search result and find best result index set
if (theSearch.getRankingResult().getLocalIndexCount() == 0) {
joincount = theSearch.getRankingResult().getLocalIndexCount();
prop.put("joincount", Integer.toString(joincount));
if (joincount != 0) {
accu = theSearch.result().completeResults(1000);
}
if (theSearch.getRankingResult().getLocalIndexCount() == 0 || abstracts.length() == 0) {
prop.put("indexcount", "");
prop.put("joincount", "0");
} else {
@ -310,15 +315,6 @@ public final class search {
}
prop.put("indexcount", indexcount.toString());
if (theSearch.getRankingResult().getLocalIndexCount() == 0) {
joincount = 0;
prop.put("joincount", "0");
} else {
joincount = theSearch.getRankingResult().getLocalIndexCount();
prop.put("joincount", Integer.toString(joincount));
accu = theSearch.result().completeResults(3000);
}
// generate compressed index for maxcounthash
// this is not needed if the search is restricted to specific
// urls, because it is a re-search
@ -353,7 +349,7 @@ public final class search {
prop.put("indexabstract", indexabstract.toString());
// prepare result
if ((joincount == 0) || (accu == null)) {
if (joincount == 0 || accu == null || accu.size() == 0) {
// no results
prop.put("links", "");

@ -92,15 +92,19 @@ public final class BufferedRecords {
}
public final synchronized void get(final long index, final byte[] b, final int start) throws IOException {
Long idx = Long.valueOf(index);
final byte[] bb;
synchronized (this) {
assert b.length - start >= efs.recordsize;
if (index >= size()) throw new IndexOutOfBoundsException("kelondroBufferedEcoFS.get(" + index + ") outside bounds (" + this.size() + ")");
final byte[] bb = buffer.get(Long.valueOf(index));
bb = buffer.get(idx);
if (bb == null) {
efs.get(index, b, start);
} else {
System.arraycopy(bb, 0, b, start, efs.recordsize);
return;
}
}
System.arraycopy(bb, 0, b, start, efs.recordsize);
}
public final synchronized void put(final long index, final byte[] b, final int start) throws IOException {
assert b.length - start >= efs.recordsize;

@ -516,20 +516,21 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSet
public static final <ReferenceType extends Reference> ByteBuffer compressIndex(final ReferenceContainer<ReferenceType> inputContainer, final ReferenceContainer<ReferenceType> excludeContainer, final long maxtime) {
// collect references according to domains
final long timeout = (maxtime < 0) ? Long.MAX_VALUE : System.currentTimeMillis() + maxtime;
final TreeMap<String, String> doms = new TreeMap<String, String>();
final TreeMap<String, StringBuilder> doms = new TreeMap<String, StringBuilder>();
synchronized (inputContainer) {
final Iterator<ReferenceType> i = inputContainer.entries();
Reference iEntry;
String dom, mod, paths;
String dom, mod;
StringBuilder paths;
while (i.hasNext()) {
iEntry = i.next();
if ((excludeContainer != null) && (excludeContainer.getReference(iEntry.metadataHash()) != null)) continue; // do not include urls that are in excludeContainer
dom = new String(iEntry.metadataHash(), 6, 6);
mod = new String(iEntry.metadataHash(), 0, 6);
if ((paths = doms.get(dom)) == null) {
doms.put(dom, mod);
doms.put(dom, new StringBuilder(30).append(mod));
} else {
doms.put(dom, paths + mod);
doms.put(dom, paths.append(mod));
}
if (System.currentTimeMillis() > timeout)
break;
@ -538,13 +539,13 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSet
// construct a result string
final ByteBuffer bb = new ByteBuffer(inputContainer.size() * 6);
bb.append('{');
final Iterator<Map.Entry<String, String>> i = doms.entrySet().iterator();
Map.Entry<String, String> entry;
final Iterator<Map.Entry<String, StringBuilder>> i = doms.entrySet().iterator();
Map.Entry<String, StringBuilder> entry;
while (i.hasNext()) {
entry = i.next();
bb.append(entry.getKey());
bb.append(':');
bb.append(entry.getValue());
bb.append(entry.getValue().toString());
if (System.currentTimeMillis() > timeout)
break;
if (i.hasNext())

Loading…
Cancel
Save