Bug 77638 - Patches for reducing matching-time
Summary: Patches for reducing matching-time
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 1.5.0   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-03 10:04 EST by Eric Bodden CLA
Modified: 2012-04-03 16:10 EDT (History)
0 users

See Also:


Attachments
First, simple, approach including test-case (13.11 KB, patch)
2004-11-03 10:05 EST, Eric Bodden CLA
aclement: iplog+
Details | Diff
First approach again, here without overhead for testcase (8.56 KB, patch)
2004-11-03 10:06 EST, Eric Bodden CLA
aclement: iplog+
Details | Diff
Second, statful approach, for AndPointcut only, with testcase (15.74 KB, patch)
2004-11-03 10:06 EST, Eric Bodden CLA
aclement: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Bodden CLA 2004-11-03 10:04:32 EST
I have put together some patches, that implement some thoughts about reducing 
matching-time by evaluating AndPointcuts and OrPointcuts lazily. This reduced 
matching costs in by about 30% in average on my tests. (testcase included)

It works as follows:

First enhancement:
For an AndPointcut, "p && q", q is only evaluated if p matches already (or 
"maybe"). Same for OrPointcut respectively.

Second enhancement:
Every pointcut now comes with a method "double matchingCosts()" that should 
return a heuristic value of how expensive it would be to test if this pointcut 
matches. This helps the AndPointcut respectively OrPointcut to figure out which 
of the both pointcuts "left" or "right" should be matched first (first try the 
easier one). Thus by giving good heuristics on how likely a pointcut is going to 
match and how expensive such a matching would be, waeve time can again be 
improved. The matchingCosts() method is not yet implemented. That's up to you 
guys to find out what appropriate values would be.

In a second approach I tried something even more powerful: Stateful AndPointcuts 
(resp. OrPointcuts):

A stateful AndPointcut firstly evaluates the "easier" side. If it sees "yes" or 
"maybe", it fully evaluates. If it sees "no", it returns "no". Up till here this 
is as above. However, if it sees "never", it switches state to "never" match in 
general. So every subsequent tests do not need to be performed again.

The drawback at the moment is that at the moment, no pointcut actually ever 
returns a FuzzyBooleanNever on matching, which seems a bit strange to me.

As future work one could probably use term rewriting techniques to reduce 
something like "call(foo) && !call(foo)" to a never-matching pointcut. This 
should increase matching time for large projects again.

At the moment however, the stateful implementation (which I provide for 
AndPointcut only here), seems to be less efficient that the first approach due 
to an indirection introduced by the call to the internal state object.

I would be very interested in further discussion on that topic.
Comment 1 Eric Bodden CLA 2004-11-03 10:05:20 EST
Created attachment 15606 [details]
First, simple, approach including test-case
Comment 2 Eric Bodden CLA 2004-11-03 10:06:05 EST
Created attachment 15607 [details]
First approach again, here without overhead for testcase
Comment 3 Eric Bodden CLA 2004-11-03 10:06:42 EST
Created attachment 15608 [details]
Second, statful approach, for AndPointcut only, with testcase
Comment 4 Eric Bodden CLA 2004-11-03 10:29:30 EST
> As future work one could probably use term rewriting techniques to
> reduce something like "call(foo) && !call(foo)" to a never-matching
> pointcut. This should increase matching time for large projects again.
Small correction: Of course I meant *decrease* here, not *increase*.
Comment 5 Adrian Colyer CLA 2005-03-23 08:53:58 EST
A variation on this idea was implemented in Aj5 m1... forgot to close out this
enh report at the time.