because newbies are scared about the memory consumption in the performance graph and arguments about high memory consumption according to bad knowledge about java garbage collection techniques, the memory display had been removed from the performance graph shown on the Status.html page. The memory graph can still be seen on the Performance page where the memory graph is just like it was.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7836 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 09bb7a390c
commit 3a191cdf14

@ -9,7 +9,7 @@
// $LastChangedBy$
//
// LICENSE
//
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
@ -32,16 +32,17 @@ import de.anomic.server.serverSwitch;
import de.anomic.yacy.graphics.ProfilingGraph;
public class PerformanceGraph {
public static RasterPlotter respond(final RequestHeader header, serverObjects post, final serverSwitch env) {
final Switchboard sb = (Switchboard) env;
if (post == null) post = new serverObjects();
final int width = post.getInt("width", 660);
final int height = post.getInt("height", 240);
return ProfilingGraph.performanceGraph(width, height, sb.indexSegments.URLCount() + " URLS / " + sb.indexSegments.RWICount() + " WORDS IN INDEX / " + sb.indexSegments.RWIBufferCount() + " WORDS IN CACHE");
final boolean showMemory = !post.containsKey("nomem");
return ProfilingGraph.performanceGraph(width, height, sb.indexSegments.URLCount() + " URLS / " + sb.indexSegments.RWICount() + " WORDS IN INDEX / " + sb.indexSegments.RWIBufferCount() + " WORDS IN CACHE", showMemory);
}
}

@ -15,7 +15,7 @@
}
}
function reloadGraph() {
document.images["graph"].src="PerformanceGraph.png?time="+(new Date()).getTime();
document.images["graph"].src="PerformanceGraph.png?nomem=&time="+(new Date()).getTime();
window.status="";
}
function init() {
@ -47,7 +47,7 @@
<h2><img src="/env/grafics/kaskelix.png" width="128" height="64" alt="YaCy Websearch" style="margin-right:5px; vertical-align:middle;" />Welcome to YaCy!</h2>
<iframe src="rssTerminal.html?set=PEERNEWS,REMOTESEARCH,LOCALSEARCH,REMOTEINDEXING,LOCALINDEXING,DHTRECEIVE,DHTSEND,PROXY&amp;width=600px&amp;height=180px&amp;maxlines=20&amp;maxwidth=120"
style="width:600px;height:180px;margin:0px;border:1px solid black;" scrolling="no" name="newsframe"></iframe><br />
<img src="PerformanceGraph.png" id="graph" alt="PerformanceGraph" width="660" height="240"/><br />
<img src="PerformanceGraph.png?nomem=" id="graph" alt="PerformanceGraph" width="660" height="240"/><br />
<img src="Banner.png?textcolor=000000&amp;bgcolor=e7effc&amp;bordercolor=5090d0" alt="banner" width="468" height="60"/>
</div>

@ -102,6 +102,7 @@ public class SearchEventCache {
private static SearchEvent dummyEvent = null;
private static SearchEvent getDummyEvent(final WorkTables workTables, final LoaderDispatcher loader, final Segment indexSegment) {
Log.logWarning("SearchEventCache", "returning dummy event");
if (dummyEvent != null) return dummyEvent;
final QueryParams query = new QueryParams("", 0, null, indexSegment, new RankingProfile(ContentDomain.TEXT), "");
dummyEvent = new SearchEvent(query, null, workTables, null, false, loader, 0, 0, 0, 0, false);

@ -9,7 +9,7 @@
// $LastChangedBy$
//
// LICENSE
//
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
@ -29,18 +29,17 @@ package de.anomic.yacy.graphics;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import de.anomic.search.SearchEvent;
import net.yacy.kelondro.util.EventTracker;
import net.yacy.kelondro.util.EventTracker.Event;
import net.yacy.visualization.RasterPlotter;
import net.yacy.visualization.ChartPlotter;
import net.yacy.visualization.RasterPlotter;
import de.anomic.search.SearchEvent;
public class ProfilingGraph {
private static ChartPlotter bufferChart = null;
public static long maxTime = 600000L;
public static long maxPayload(final EventTracker.EClass eventname, final long min) {
final Iterator<Event> list = EventTracker.getHistory(eventname);
if (list == null) return min;
@ -55,21 +54,21 @@ public class ProfilingGraph {
}
return max;
}
public static RasterPlotter performanceGraph(final int width, final int height, final String subline) {
public static RasterPlotter performanceGraph(final int width, final int height, final String subline, final boolean showMemory) {
// find maximum values for automatic graph dimension adoption
final int maxppm = (int) maxPayload(EventTracker.EClass.PPM, 25);
final int maxwords = (int) maxPayload(EventTracker.EClass.WORDCACHE, 12000);
final long maxbytes = maxPayload(EventTracker.EClass.MEMORY, 110 * 1024 * 1024);
final int maxmbytes = (int)(maxbytes / 1024 / 1024);
// declare graph and set dimensions
final int leftborder = 30;
final int rightborder = 30;
final int topborder = 20;
final int bottomborder = 20;
final int leftscale; if(maxwords > 150000) leftscale = maxwords / 150000 * 20000; else leftscale = 10000;
final int rightscale; if (maxmbytes > 1500) rightscale = maxmbytes / 1500 * 200; else rightscale = 100;
final int leftscale = (maxwords > 150000) ? maxwords / 150000 * 20000 : 10000;
final int rightscale = showMemory ? ((maxmbytes > 1500) ? maxmbytes / 1500 * 200 : 100) : Math.max(100, maxppm / 100 * 100);
final int anotscale = 1000;
final int bottomscale = 60;
final int vspace = height - topborder - bottomborder;
@ -77,11 +76,15 @@ public class ProfilingGraph {
final int maxtime = 600;
ChartPlotter chart = new ChartPlotter(width, height, "FFFFFF", "000000", "AAAAAA", leftborder, rightborder, topborder, bottomborder, "YACY PEER PERFORMANCE: MAIN MEMORY, WORD CACHE AND PAGES/MINUTE (PPM)", subline);
chart.declareDimension(ChartPlotter.DIMENSION_BOTTOM, bottomscale, hspace / (maxtime / bottomscale), -maxtime, "000000", "CCCCCC", "TIME/SECONDS");
chart.declareDimension(ChartPlotter.DIMENSION_LEFT, leftscale, vspace * leftscale / maxwords, 0, "008800", null , "INDEXING, WORDS IN CACHE");
chart.declareDimension(ChartPlotter.DIMENSION_RIGHT, rightscale, vspace * rightscale / maxmbytes, 0, "0000FF", "CCCCCC", "MEMORY/MEGABYTE");
chart.declareDimension(ChartPlotter.DIMENSION_LEFT, leftscale, vspace * leftscale / maxwords, 0, "008800", null , "WORDS IN INDEXING CACHE");
if (showMemory) {
chart.declareDimension(ChartPlotter.DIMENSION_RIGHT, rightscale, vspace * rightscale / maxmbytes, 0, "0000FF", "CCCCCC", "MEMORY/MEGABYTE");
} else {
chart.declareDimension(ChartPlotter.DIMENSION_RIGHT, rightscale, vspace * rightscale / Math.max(1, maxppm), 0, "FF0000", "CCCCCC", "INDEXING SPEED/PAGES PER MINUTE");
}
chart.declareDimension(ChartPlotter.DIMENSION_ANOT0, anotscale, vspace * anotscale / maxppm, 0, "008800", null , "PPM [PAGES/MINUTE]");
chart.declareDimension(ChartPlotter.DIMENSION_ANOT1, vspace / 6, vspace / 6, 0, "888800", null , "URL");
// draw chart
long time;
final long now = System.currentTimeMillis();
@ -104,25 +107,28 @@ public class ProfilingGraph {
x0 = x1; y0 = y1;
}
*/
Iterator<Event> events;
// draw memory
Iterator<Event> events = EventTracker.getHistory(EventTracker.EClass.MEMORY);
x0 = 1; y0 = 0;
if (events != null) {
EventTracker.Event event;
while (events.hasNext()) {
event = events.next();
time = event.time - now;
bytes = ((Long) event.payload).longValue();
x1 = (int) (time/1000);
y1 = (int) (bytes / 1024 / 1024);
chart.setColor("AAAAFF");
chart.chartDot(ChartPlotter.DIMENSION_BOTTOM, ChartPlotter.DIMENSION_RIGHT, x1, y1, 2, null, 0);
chart.setColor("0000FF");
if (x0 < 0) chart.chartLine(ChartPlotter.DIMENSION_BOTTOM, ChartPlotter.DIMENSION_RIGHT, x0, y0, x1, y1);
x0 = x1; y0 = y1;
if (showMemory) {
events = EventTracker.getHistory(EventTracker.EClass.MEMORY);
x0 = 1; y0 = 0;
if (events != null) {
EventTracker.Event event;
while (events.hasNext()) {
event = events.next();
time = event.time - now;
bytes = ((Long) event.payload).longValue();
x1 = (int) (time/1000);
y1 = (int) (bytes / 1024 / 1024);
chart.setColor("AAAAFF");
chart.chartDot(ChartPlotter.DIMENSION_BOTTOM, ChartPlotter.DIMENSION_RIGHT, x1, y1, 2, null, 0);
chart.setColor("0000FF");
if (x0 < 0) chart.chartLine(ChartPlotter.DIMENSION_BOTTOM, ChartPlotter.DIMENSION_RIGHT, x0, y0, x1, y1);
x0 = x1; y0 = y1;
}
}
}
// draw wordcache
events = EventTracker.getHistory(EventTracker.EClass.WORDCACHE);
x0 = 1; y0 = 0;
@ -141,7 +147,7 @@ public class ProfilingGraph {
x0 = x1; y0 = y1;
}
}
// draw ppm
events = EventTracker.getHistory(EventTracker.EClass.PPM);
x0 = 1; y0 = 0;
@ -160,23 +166,23 @@ public class ProfilingGraph {
x0 = x1; y0 = y1;
}
}
bufferChart = chart;
} catch (final ConcurrentModificationException cme) {
chart = bufferChart;
}
return chart;
}
public static class searchEvent {
public SearchEvent.Type processName;
public String comment;
public String queryID;
public long duration;
public int resultCount;
public searchEvent(final String queryID, final SearchEvent.Type processName, String comment, final int resultCount, final long duration) {
public searchEvent(final String queryID, final SearchEvent.Type processName, final String comment, final int resultCount, final long duration) {
this.queryID = queryID;
this.processName = processName;
this.comment = comment;
@ -184,5 +190,5 @@ public class ProfilingGraph {
this.duration = duration;
}
}
}

@ -1,4 +1,4 @@
// ChartPlotter.java
// ChartPlotter.java
// ---------------------------
// (C) by Michael Peter Christen; mc@yacy.net
// first published on http://www.anomic.de
@ -33,25 +33,25 @@ import javax.imageio.ImageIO;
public class ChartPlotter extends RasterPlotter {
public static final int DIMENSION_RIGHT = 0;
public static final int DIMENSION_TOP = 1;
public static final int DIMENSION_LEFT = 2;
public static final int DIMENSION_BOTTOM = 3;
public static final int DIMENSION_ANOT0 = 4;
public static final int DIMENSION_ANOT1 = 5;
private int leftborder;
private int rightborder;
private int topborder;
private int bottomborder;
private int[] scales = new int[]{0,0,0,0,0,0};
private int[] pixels = new int[]{0,0,0,0,0,0};
private int[] offsets = new int[]{0,0,0,0,0,0};
private String[] colnames = new String[]{"FFFFFF","FFFFFF","FFFFFF","FFFFFF","FFFFFF","FFFFFF"};
private String[] colscale = new String[]{null,null,null,null,null,null};
private String[] tablenames = new String[]{"","","","","",""};
private final int leftborder;
private final int rightborder;
private final int topborder;
private final int bottomborder;
private final int[] scales = new int[]{0,0,0,0,0,0};
private final int[] pixels = new int[]{0,0,0,0,0,0};
private final int[] offsets = new int[]{0,0,0,0,0,0};
private final String[] colnames = new String[]{"FFFFFF","FFFFFF","FFFFFF","FFFFFF","FFFFFF","FFFFFF"};
private final String[] colscale = new String[]{null,null,null,null,null,null};
private final String[] tablenames = new String[]{"","","","","",""};
public ChartPlotter(final int width, final int height, final String backgroundColor, final String foregroundColor, final String lightColor,
final int leftborder, final int rightborder, final int topborder, final int bottomborder,
final String name, final String subline) {
@ -72,7 +72,7 @@ public class ChartPlotter extends RasterPlotter {
PrintTool.print(this, width / 2 - subline.length() * 3, 14, 0, subline, -1);
}
}
public void declareDimension(final int dimensionType, final int scale, final int pixelperscale, final int offset, final String colorNaming, final String colorScale, final String name) {
if ((dimensionType == DIMENSION_LEFT) || (dimensionType == DIMENSION_RIGHT)) {
drawVerticalScale((dimensionType == DIMENSION_LEFT), scale, pixelperscale, offset, colorNaming, colorScale, name);
@ -80,38 +80,38 @@ public class ChartPlotter extends RasterPlotter {
if ((dimensionType == DIMENSION_TOP) || (dimensionType == DIMENSION_BOTTOM)) {
drawHorizontalScale((dimensionType == DIMENSION_TOP), scale, pixelperscale, offset, colorNaming, colorScale, name);
}
scales[dimensionType] = scale;
pixels[dimensionType] = pixelperscale;
offsets[dimensionType] = offset;
colnames[dimensionType] = colorNaming;
colscale[dimensionType] = colorScale;
tablenames[dimensionType] = name;
this.scales[dimensionType] = scale;
this.pixels[dimensionType] = pixelperscale;
this.offsets[dimensionType] = offset;
this.colnames[dimensionType] = colorNaming;
this.colscale[dimensionType] = colorScale;
this.tablenames[dimensionType] = name;
}
public void chartDot(final int dimension_x, final int dimension_y, final int coord_x, final int coord_y, final int dotsize, String anot, int anotAngle) {
final int x = (coord_x - offsets[dimension_x]) * pixels[dimension_x] / scales[dimension_x];
final int y = (coord_y - offsets[dimension_y]) * pixels[dimension_y] / scales[dimension_y];
if (dotsize == 1) plot(leftborder + x, height - bottomborder - y, 100);
else dot(leftborder + x, height - bottomborder - y, dotsize, true, 100);
if (anot != null) PrintTool.print(this, leftborder + x + dotsize + 2 + ((anotAngle == 315) ? -9 : 0), height - bottomborder - y + ((anotAngle == 315) ? -3 : 0), anotAngle, anot, (anotAngle == 0) ? -1 : ((anotAngle == 315) ? 1 : 0));
public void chartDot(final int dimension_x, final int dimension_y, final int coord_x, final int coord_y, final int dotsize, final String anot, final int anotAngle) {
final int x = (coord_x - this.offsets[dimension_x]) * this.pixels[dimension_x] / this.scales[dimension_x];
final int y = (coord_y - this.offsets[dimension_y]) * this.pixels[dimension_y] / this.scales[dimension_y];
if (dotsize == 1) plot(this.leftborder + x, this.height - this.bottomborder - y, 100);
else dot(this.leftborder + x, this.height - this.bottomborder - y, dotsize, true, 100);
if (anot != null) PrintTool.print(this, this.leftborder + x + dotsize + 2 + ((anotAngle == 315) ? -9 : 0), this.height - this.bottomborder - y + ((anotAngle == 315) ? -3 : 0), anotAngle, anot, (anotAngle == 0) ? -1 : ((anotAngle == 315) ? 1 : 0));
}
public void chartLine(final int dimension_x, final int dimension_y, final int coord_x1, final int coord_y1, final int coord_x2, final int coord_y2) {
final int x1 = (coord_x1 - offsets[dimension_x]) * pixels[dimension_x] / scales[dimension_x];
final int y1 = (coord_y1 - offsets[dimension_y]) * pixels[dimension_y] / scales[dimension_y];
final int x2 = (coord_x2 - offsets[dimension_x]) * pixels[dimension_x] / scales[dimension_x];
final int y2 = (coord_y2 - offsets[dimension_y]) * pixels[dimension_y] / scales[dimension_y];
line(leftborder + x1, height - bottomborder - y1, leftborder + x2, height - bottomborder - y2, 100);
final int x1 = (coord_x1 - this.offsets[dimension_x]) * this.pixels[dimension_x] / this.scales[dimension_x];
final int y1 = (coord_y1 - this.offsets[dimension_y]) * this.pixels[dimension_y] / this.scales[dimension_y];
final int x2 = (coord_x2 - this.offsets[dimension_x]) * this.pixels[dimension_x] / this.scales[dimension_x];
final int y2 = (coord_y2 - this.offsets[dimension_y]) * this.pixels[dimension_y] / this.scales[dimension_y];
line(this.leftborder + x1, this.height - this.bottomborder - y1, this.leftborder + x2, this.height - this.bottomborder - y2, 100);
}
private void drawHorizontalScale(final boolean top, final int scale, final int pixelperscale, final int offset, final String colorNaming, final String colorScale, final String name) {
final int y = (top) ? topborder : height - bottomborder;
int x = leftborder;
final int y = (top) ? this.topborder : this.height - this.bottomborder;
int x = this.leftborder;
int s = offset;
while (x < width - rightborder) {
if ((colorScale != null) && (x > leftborder) && (x < (width - rightborder))) {
while (x < this.width - this.rightborder) {
if ((colorScale != null) && (x > this.leftborder) && (x < (this.width - this.rightborder))) {
setColor(colorScale);
line(x, topborder, x, height - bottomborder, 100);
line(x, this.topborder, x, this.height - this.bottomborder, 100);
}
setColor(colorNaming);
line(x, y - 3, x, y + 3, 100);
@ -120,34 +120,36 @@ public class ChartPlotter extends RasterPlotter {
s += scale;
}
setColor(colorNaming);
PrintTool.print(this, width - rightborder, (top) ? y - 9 : y + 15, 0, name, 1);
line(leftborder - 4, y, width - rightborder + 4, y, 100);
PrintTool.print(this, this.width - this.rightborder, (top) ? y - 9 : y + 15, 0, name, 1);
line(this.leftborder - 4, y, this.width - this.rightborder + 4, y, 100);
}
private void drawVerticalScale(final boolean left, final int scale, final int pixelperscale, final int offset, final String colorNaming, final String colorScale, final String name) {
final int x = (left) ? leftborder : width - rightborder;
int y = height - bottomborder;
assert pixelperscale > 0;
assert scale > 0;
final int x = (left) ? this.leftborder : this.width - this.rightborder;
int y = this.height - this.bottomborder;
int s = offset;
String s1;
int s1max = 0;
while (y > topborder) {
if ((colorScale != null) && (y > topborder) && (y < (height - bottomborder))) {
while (y > this.topborder) {
if ((colorScale != null) && (y > this.topborder) && (y < (this.height - this.bottomborder))) {
setColor(colorScale);
line(leftborder, y, width - rightborder, y, 100);
line(this.leftborder, y, this.width - this.rightborder, y, 100);
}
setColor(colorNaming);
line(x - 3, y, x + 3, y, 100);
s1 = (s >= 1000000 && s % 10000 == 0) ? Integer.toString(s / 1000000) + "M" : (s >= 1000 && s % 1000 == 0) ? Integer.toString(s / 1000) + "K" : Integer.toString(s);
if (s1.length() > s1max) s1max = s1.length();
PrintTool.print(this, (left) ? leftborder - 4 : width - rightborder + 4, y, 0, s1, (left) ? 1 : -1);
PrintTool.print(this, (left) ? this.leftborder - 4 : this.width - this.rightborder + 4, y, 0, s1, (left) ? 1 : -1);
y -= pixelperscale;
s += scale;
}
setColor(colorNaming);
PrintTool.print(this, (left) ? x - s1max * 6 - 6 : x + s1max * 6 + 9, topborder, 90, name, 1);
line(x, topborder - 4, x, height - bottomborder + 4, 100);
PrintTool.print(this, (left) ? x - s1max * 6 - 6 : x + s1max * 6 + 9, this.topborder, 90, name, 1);
line(x, this.topborder - 4, x, this.height - this.bottomborder + 4, 100);
}
public static void main(final String[] args) {
System.setProperty("java.awt.headless", "true");
final String bg = "FFFFFF";
@ -176,7 +178,7 @@ public class ChartPlotter extends RasterPlotter {
ImageIO.write(ip.getImage(), "png", fos);
fos.close();
} catch (final IOException e) {}
}
}

Loading…
Cancel
Save