[abc] Tracematch/cflowdepth slowdowns in the presence of threads

From: Neil Ongkingco <neil.ongkingco@keble.ox.ac.uk>
Date: Sun Dec 11 2005 - 16:39:54 GMT

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 Sun Dec 11 16:40:06 2005

This archive was generated by hypermail 2.1.8 : Mon Dec 12 2005 - 19:40:07 GMT