I modified the tracematch to separate the threads (by using let):
aspect LockTraceMatch {
private static boolean debug;
private void debPrint(String s) {
System.out.println(s);
}
pointcut anyfunc() : execution( * *(..)) && !within(LockTraceMatch);
pointcut lock(A r) :
execution(* A.lock()) && target(r);
pointcut unlock(A r) :
execution(* A.unlock()) && target(r);
pointcut currThread(Thread t) : let(t, Thread.currentThread());
//generates a memory leak warning
tracematch(A r, int i, Thread t) {
sym beforefunc before : anyfunc() && cflowdepth(i, anyfunc()) &&
currThread(t);
sym afterfunc after : anyfunc() && cflowdepth(i, anyfunc()) &&
currThread(t);
sym lock after : lock(r) && cflowbelowdepth(i, anyfunc()) &&
currThread(t);
sym unlock after : unlock(r) && cflowbelowdepth(i, anyfunc()) &&
currThread(t);
beforefunc lock afterfunc {
try {
throw new Exception("Unmatched lock");
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
It got rid of some false matches, but runs even slower than the original
version. I use an almost identical tracematch on Jigsaw, and I can't get
the benchmark to go for more than 20 iterations before the server bogs
down (more than 1 minute per iteration). In comparison, the unmodified
version and the aspect version take about 1 ms per iteration, and I was
able to run 100000 iterations on both (albeit with some errors in the
aspect version).
Neil
Neil Ongkingco wrote:
> Apologies if this is a duplicate email. I made the mistake of putting
> attachments, which apparently delays my emails by quite a bit.
>
> I'm experiencing serious slowdowns when using tracematches on the
> Jigsaw code. I think its because Jigsaw uses a lot of threads, and the
> attached code demonstrates the slowdown on a small example that uses
> 10 threads. I'm not sure exactly what causes the slowdown, as the
> memory usage isn't really that high. As such I can't really run the
> benchmark on Jigsaw (it freezes after about 20 responses to a GET).
>
> Is there something wrong with the tracematch that causes the slowdown?
> Is there any other way that I can express LockTraceMatch? It seems to
> be the most obvious way of expressing a pattern that detects locks
> that are not matched by unlocks in the same method, but if anyone has
> a better idea, I would like to try it, to see if it does not cause the
> slowdown.
>
> Here's the code:
>
> aspect LockTraceMatch {
>
> private static boolean debug;
> private void debPrint(String s) {
> System.out.println(s);
> }
>
> pointcut anyfunc() : execution( * *(..)) && !within(LockTraceMatch);
>
> pointcut lock(A r) :
> execution(* A.lock()) && target(r);
>
> pointcut unlock(A r) :
> execution(* A.unlock()) && target(r);
>
> //generates a memory leak warning
> tracematch(A r, int i) {
>
> sym beforefunc before : anyfunc() && cflowdepth(i, anyfunc());
> sym afterfunc after : anyfunc() && cflowdepth(i, anyfunc());
> sym lock after : lock(r) && cflowbelowdepth(i, anyfunc());
> sym unlock after : unlock(r) && cflowbelowdepth(i, anyfunc());
>
> beforefunc lock afterfunc {
> try {
> throw new Exception("Unmatched lock");
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
> }
>
> public class Main {
> static void f(A a) {
> a.lock();
> a.unlock();
> }
>
> static void g(A a) {
> a.lock();
> }
>
> static void h(A a) {
> a.lock();
> f(a);
> g(a);
> a.unlock();
> }
>
> static void k(A a) {
> a.lock();
> f(a);
> g(a);
> }
>
> static void test() {
> A a = new A();
> f(a);
> g(a);
> h(a);
> k(a);
> }
>
> private static class TestThread extends Thread {
> public void run() {
> test();
> }
> }
>
> public static void main(String args[]) {
> //This runs fast
> for (int i = 0; i < 10; i++) {
> test();
> }
>
> //This starts out fast, but slows down consderably
> for (int i = 0; i < 10; i++) {
> Thread t = new TestThread();
> t.start();
> }
> }
>
> }
>
> class A {
> A lock() {
> System.out.println("A.lock");
> return this;
> }
> void unlock() {
> System.out.println("A.unlock");
> return;
> }
> }
>
>
>
> Neil
>
>
>
Received on Mon Dec 12 19:35:29 2005
This archive was generated by hypermail 2.1.8 : Tue Dec 13 2005 - 03:20:08 GMT