Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

performance hacks

orbiter9e4875230f70
diff --git a/htroot/yacy/idx.java b/htroot/yacy/idx.java
index 6384a5cf3..348c42b38 100644
--- a/htroot/yacy/idx.java
+++ b/htroot/yacy/idx.java
@@ -63,7 +63,7 @@ public final class idx {
for (final ReferenceContainer<HostReference> references: idx) {
prop.put("list_" + count + "_term", ASCII.String(references.getTermHash()));
final Iterator<HostReference> referenceIterator = references.entries();
- final StringBuilder s = new StringBuilder();
+ final StringBuilder s = new StringBuilder(references.size() * 20); // pre-set of guessed size reduces expandCapacity() and increases performance
HostReference reference;
while (referenceIterator.hasNext()) {
reference = referenceIterator.next();
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index 8e5ea534f..0197eb7c5 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -728,7 +728,7 @@ public class yacysearch {
prop.put("num-results_globalresults_remotePeerCount", Formatter.number(theSearch.getRankingResult().getRemotePeerCount(), true));
// compose page navigation
- final StringBuilder resnav = new StringBuilder();
+ final StringBuilder resnav = new StringBuilder(200);
final int thispage = offset / theQuery.displayResults();
if (thispage == 0) {
resnav.append("<img src=\"env/grafics/navdl.gif\" alt=\"arrowleft\" width=\"16\" height=\"16\" />&nbsp;");
diff --git a/source/de/anomic/http/server/HTTPDemon.java b/source/de/anomic/http/server/HTTPDemon.java
index c0b06c7c3..e705b34c6 100644
--- a/source/de/anomic/http/server/HTTPDemon.java
+++ b/source/de/anomic/http/server/HTTPDemon.java
@@ -96,7 +96,8 @@ public final class HTTPDemon implements serverHandler, Cloneable {
public static final int ERRORCASE_MESSAGE = 4;
public static final int ERRORCASE_FILE = 5;
private static final File TMPDIR = new File(System.getProperty("java.io.tmpdir"));
- private static final FileItemFactory DISK_FILE_ITEM_FACTORY = new DiskFileItemFactory(5 * 1024 * 1024, TMPDIR);
+ private static final int SIZE_FILE_THRESHOLD = 20 * 1024 * 1024;
+ private static final FileItemFactory DISK_FILE_ITEM_FACTORY = new DiskFileItemFactory(SIZE_FILE_THRESHOLD, TMPDIR);
private static AlternativeDomainNames alternativeResolver = null;
@@ -815,6 +816,9 @@ public final class HTTPDemon implements serverHandler, Cloneable {
throw new IOException("the request is not a multipart-message!");
}
+ // reject too large uploads
+ if (request.getContentLength() > SIZE_FILE_THRESHOLD) throw new IOException("FileUploadException: uploaded file too large = " + request.getContentLength());
+
// check if we have enough memory
if (!MemoryControl.request(request.getContentLength() * 3, false)) {
throw new IOException("not enough memory available for request. request.getContentLength() = " + request.getContentLength() + ", MemoryControl.available() = " + MemoryControl.available());