My Photo

Become a Fan

DailyMile

Google Ad Skyscraper

« BTrace experience continued | Main | Single Partition and every-partition transactions »

June 08, 2009

Comments

Jaroslav Bachorik

Hi Billy,
I tried to "optimize" the script a bit. Basically, I replaced the duplicated probe methods with regex matching and put there Deque to work in order to keep track of enter/exit times.

I hope the formatting won't get screwed up too much ...
===========================================

import static com.sun.btrace.BTraceUtils.*;

import com.sun.btrace.AnyType;
import com.sun.btrace.BTraceUtils;
import com.sun.btrace.aggregation.Aggregation;
import com.sun.btrace.aggregation.AggregationFunction;
import com.sun.btrace.aggregation.AggregationKey;
import com.sun.btrace.annotations.BTrace;
import com.sun.btrace.annotations.Kind;
import com.sun.btrace.annotations.Location;
import com.sun.btrace.annotations.OnMethod;
import com.sun.btrace.annotations.OnTimer;
import com.sun.btrace.annotations.TLS;
import java.util.Deque;

/**
* BTrace script to print timings for all executed Agents on an event.
*
*
* @author Billy Newport
* @author Jaroslav Bachorik
*/
@BTrace
public class PQLoaderTimer {

private static Aggregation histogram = newAggregation(AggregationFunction.QUANTIZE);

private static Aggregation average = newAggregation(AggregationFunction.AVERAGE);

private static Aggregation max = newAggregation(AggregationFunction.MAXIMUM);

private static Aggregation min = newAggregation(AggregationFunction.MINIMUM);

private static Aggregation sum = newAggregation(AggregationFunction.SUM);

private static Aggregation count = newAggregation(AggregationFunction.COUNT);

private static Aggregation globalCount = newAggregation(AggregationFunction.COUNT);

@TLS
private static Deque timeStamps = newDeque();

@OnMethod(clazz = "/purequery\\.loader\\.(GenericPQLoader|PQTxCallback)/", method = "/(get|batchUpdate|commit)/")
public static void onGet() {
push(timeStamps, timeNanos());
}

@OnMethod(clazz = "/purequery\\.loader\\.(GenericPQLoader|PQTxCallback)/", method = "/(get|batchUpdate|commit)/", location = @Location(Kind.RETURN))
public static void onCallMapAgentReturn()
{
long timeStampNanos = poll(timeStamps);
String executingVerb = probeMethod();
AggregationKey key = newAggregationKey(executingVerb);
int duration = (int) (timeNanos() - timeStampNanos) / 1000;
BTraceUtils.print("Duration of "); BTraceUtils.print(executingVerb); BTraceUtils.print(" "); BTraceUtils.println(duration);

addToAggregation(histogram, key, duration);
addToAggregation(average, key, duration);
addToAggregation(max, key, duration);
addToAggregation(min, key, duration);
addToAggregation(sum, key, duration);
addToAggregation(count, key, duration);
addToAggregation(globalCount, duration);
}

@OnTimer(5000)
public static void onEvent() {

// Top 20 agents only
BTraceUtils.truncateAggregation(histogram, 20);

println("---------------------------------------------");
printAggregation("Count", count);
printAggregation("Min", min);
printAggregation("Max", max);
printAggregation("Average", average);
printAggregation("Sum", sum);
printAggregation("Histogram", histogram);
printAggregation("Global Count", globalCount);
println("---------------------------------------------");
}
}

A.O.P I am tired of technology

The script does not cater for overloaded methods within a class or same named methods in the call (stack) path. It will overstate and incorrectly report statistics.

Dutch: Hey Billy, give me a way out of this hole. Aerial says we are cut off.
Billy: The only way outta here is that valley that leads to the east. But I wouldn't wish that on a broke-dick dog.
Dutch: Not much choice.

Jaroslav Bachorik

@A.O.P (or William Louth or whoever)
Yes, the script doesn't cater for those eventualities. The question is if that's necessary - the user (Billy) might be 100% sure there won't be such cases and then getting method signatures or checking the stack traces would mean an unneeded overhead.

BTrace is not a golden hammer - sometimes it fits the task, sometimes it doesn't. It is up to the user to decide.

Jaroslav Bachorik

See http://opencore.jinspired.com/?page_id=588 - A.O.P. (William Louth) - you could at least give a credit to Billy (if not me) for the script you are using in your unbiased comparison :)

I would really like to get hold of you trial version to do my "unbiased" comparison.

And I must repeat - BTrace is as much Sun product as Linux is eg. Novel product. It just happens that 2 main contributors are (yet) employees of Sun. The project is not funded by the company (they don't own my spare time) and as such I don't see it as a threat to the full blown commercial solutions. Do you?

A.O.P I am tired of technology

You seems to have real problems with integrity including your reporting here and may I say within your homegrown (in the sun) solutions.

The posting date of the article referenced appears to be earlier than your own posting. It also appears to have been posted to DZone earlier. I wonder how long it would take to write a btrace script and then benchmark 100 million times (calls) it when it has an overhead of 16 micoseconds per call. Do the maths.

Fortunately the article does state the limitations of the script and BTrace which you failed to mention.

No credit?

Sergeant Prendergast: Let's meet a couple of police officers. They are all good guys.
Bill Foster: I'm the bad guy?
Sergeant Prendergast: Yeah.
Bill Foster: How did that happen?

Jaroslav Bachorik

Where do you see that it appeared earlier on DZone? It has the same date.

It seems to me that it is you who has problem with BTrace. I am not stalking the jxInsight articles and am not posting comments how much it sucks and how much better "the only right solution" is. If you are not afraid and have nothing to hide why not to enable comments in your blog?

JXOutside

Looks like JXInsight must be a real piece of shit when it tries to compete with free opensource tools. Looking at the article, I wouldn't spend a penny for this and go for the BTrace.

The comments to this entry are closed.