Re: Re: Re: [rules-users] Re: Drools performance issue
by Greg Barton
It's happening because the problem is hard. :) It's quadratic on the average number of assignments per driver. i.e. for each driver, you compare all of the assignments to each other, and you must do that for all drivers. So you have ( (num drivers) * (average num assignments)^2 ) firings in the BEST case. (The rule you originally presented was pretty much the worst case, as you were matching ( (num drivers)^2 *(num trips)^2 ) )
That's also why the processing happens when you insert the second set: before that the rule doesn't trigger.
Now, if you don't need to compare trip assignments between drivers, you could just insert one driver plus their trips and fire the rules.
But if you do want to throw everything in WM at once, you may be able to use this trick: to detect overlap, you can cut the number of conditions you've got in half, making things slightly better. You only need to detect that the start or end of one of the trips is contained in another. Also, is it possible to have a driverId attribute in your trip object? That would eliminate the need to match on the driver object. Using both you'd have this:
rule "Assignment Check"
when
$ta1: TripVO();
$ta2: TripVO(
ta1.driverId == driverId,
ta1.startDtmUtc < startDtmUtc,
ta1.endDtmUtc >= startDtmUtc
);
then
Note the "ta1.startDtmUtc < startDtmUtc" instead of ta1.startDtmUtc <= startDtmUtc". This ensures that you don't test the same two TripVOs twice.
Give this a try.
--- On Mon, 6/1/09, jayadevan.m(a)gmail.com <jayadevan.m(a)gmail.com> wrote:
> From: jayadevan.m(a)gmail.com <jayadevan.m(a)gmail.com>
> Subject: Re: Re: Re: [rules-users] Re: Drools performance issue
> To: "Wolfgang Laun" <wolfgang.laun(a)gmail.com>
> Cc: rules-users(a)lists.jboss.org
> Date: Monday, June 1, 2009, 8:34 AM
> Hi,
>
>
>
> I noticed something interesting. The issue with
> memory is happening always while inserting the second set of
> objects into working memory!
>
> Earlier, I was insering the DriverVO's into WM
> and then inserting the AssignmentsVO, and the system was
> hanging while inserting the AssignmentsVO. Then I reversed
> the order of insertion and then the machine was hit while
> inserting the DriverVO's.
>
>
>
> Does anyone know why this issue might be happening
> and how to overcome this?
>
>
>
> Thanks in advance,
>
> Jayadevan.
>
>
>
> On Jun 1, 2009 6:51pm, jayadevan.m(a)gmail.com wrote:
>
> > Thanks W,
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > I tried it out ,But didn't get any
> performance improvement :(
>
> >
>
> >
>
> > The issue might be that I am inserting too many
> objects into working memory
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > jayadevan
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > On Jun 1, 2009 3:36pm, Wolfgang Laun
> wolfgang.laun(a)gmail.com> wrote:
>
> >
>
> >
>
> > > The first two patterns pair each driver
> assignment with each trip -
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > which is quite a lot of work to do. (The
> infix "and" between the 2nd
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > and 3rd pattern doesn't change this.)
> Also, the field restriction
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > "tripId in ($tid)" is not the
> most efficient way.
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > Try this:
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > rule "Assignment Check"
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > when
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > $creVo: DriverAssignVO($drId: driverId,
> $tid1: tripId)
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > $creVo: DriverAssignVO(driverId ==
> $drId, $tid2: tripId != $tid1)
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > $trAsgn1: TripVO( tripId == $tid1,
> $startDtmUtc: startDtmUtc,
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > $endDtmUtc: endDtmUtc)
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > $trAsgn2: TripVO( tripId == $tid2,
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > ((startDtmUtc
> >= $startDtmUtc && startDtmUtc
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > (endDtmUtc >=
> $startDtmUtc && endDtmUtc
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > then
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > System.out.println("TRIP ID: "
> + $crvo.getTripId());
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > end
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > Here the first two patterns produce all
> pairs of assignments of a
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > single driver, and the remainder checks for
> overlaps.
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > You'll also find that this produces two
> symmetric firings for each
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > overlap. It might be possible to avoid this
> by using "$tid2: tripId >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > $tid1" in the second pattern, the
> id's data type permitting.
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > -W
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > 2009/6/1 Mark Proctor
> mproctor(a)redhat.com>:
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > Please send these emails to the user
> list (in cc) so everyone can help, not
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > directly to me.
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > Mark
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > jayadevan m wrote:
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > Hi
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > We have one performance(memory)
> issue in drools-5
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > Our Scenario
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > We have 3 entities
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > Trip - Entity representing details
> about trip
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > Driver - Entity for driver , it
> contain details about driver
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > Assignments - details about each
> assignments (one driver may assigned to
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > many trip)
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > The rule is to find ,"Find
> overlapping between trip assignments"
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > For Implementing this we take the
> Trip ,Driver And Assignments entities
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > from Data base and put it into working
> memory
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > For Small number of records this
> rule work well ,
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > But we want to check it against 15000
> driver ,331176 assignments and 12745
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > trips
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > In that case it take huge amount of
> time for execution (rule firing )
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > Rule is
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > rule "Assignment Check"
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > when
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > $creVo:
> DriverAssignVO($drId: driverId ,$tid: tripId);
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> $tripAssignment: TripVO(
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> $tpid: tripId,
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> $startDtmUtc: startDtmUtc,
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> $endDtmUtc: endDtmUtc)
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> and
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> $trvo: TripVO(
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> tripId != $tpid,
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> tripId in ($tid),
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> ((startDtmUtc >= $startDtmUtc
> && startDtmUtc
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > $endDtmUtc) ||
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> (endDtmUtc >= $startDtmUtc &&
> endDtmUtc
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > $endDtmUtc)));
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > $crvo:
> DriverAssignVO($drvrId: driverId , driverId == $drId ,
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > tripId != $tid, tripId == $tpid)
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > then
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> System.out.println("TRIP ID: " +
> $crvo.getTripId());
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > end
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > thanks and regards
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> _______________________________________________
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > rules-users mailing list
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > > rules-users(a)lists.jboss.org
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
> https://lists.jboss.org/mailman/listinfo/rules-users
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
> _______________________________________________
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > rules-users mailing list
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > > rules-users(a)lists.jboss.org
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
> https://lists.jboss.org/mailman/listinfo/rules-users
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
>
> >
>
> >
>
> > >
> -----Inline Attachment Follows-----
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
17 years
Web services integration for Drools Flow
by Ajay.Gautam@rbs.com
Hello,
I am evaluating a few workflow engines for an up coming project. Drools flow is the first one I am looking at.
Question: Is there any existing web services integration with Drools Flow? Specifically:
1. ability to call a service (Similar to "Email" work item)
2. ability to trigger a flow based on web services input (listener)
I could write a web services wrapper around Drools Flow, but am wondering if there is an existing solution for it. A quick Google search did not reveal anything much.
PS: Not looking at jBPM - don't want to get into deploying and maintaining a J2EE container. For our (simple) purposes, something like tomcat would suffice.
Any pointers in the right direction would be greatly appreciated.
Thanks
Ajay
*****Please note that my email address may have changed. For all
future correspondence, please use this address*****
********************************************************************This
message (including any attachments) is confidential and/or
privileged. It is to be used by the intended recipients only. If
you have received it by mistake please notify the sender by return
e-mail and delete this message from your system. Any unauthorized
use or dissemination of this message in whole or in part is
strictly prohibited. Please note that e-mails are inherently
insecure and susceptible to change. The Royal Bank of Scotland
Group, plc ("RBS") and its US subsidiaries, and affiliates and
subsidiary undertakings, including but not limited to, RBS plc New
York and Connecticut Branches, RBS Securities Inc., ABN AMRO Bank
N.V. New York and Chicago Branches and, ABN AMRO Incorporated,
Citizens Financial Group, Inc. and RBS Citizens, N.A., shall not be
liable for the improper or incomplete transmission of the
information contained in this communication or Attachment nor for
any delay in its receipt or damage to your system. RBS does not
guarantee that the integrity of this communication has been
maintained nor that this communication is free of viruses,
interceptions or interference. RBS and its subsidiaries and
affiliates do not guarantee the accuracy of any email or
attachment, that an email will be received or that RBS or its
affiliates and subsidiaries will respond to an email.
RBS makes no representations that any information contained in this
message (including any attachments) are appropriate for use in all
locations or that transactions, securities, products, instruments
or services discussed herein are available or appropriate for sale
or use in all jurisdictions, or by all investors or counterparties.
Those who utilize this information do so on their own initiative
and are responsible for compliance with applicable local laws or
regulations.********************************************************************
17 years
Re: Drools performance issue
by Mark Proctor
Please send these emails to the user list (in cc) so everyone can help,
not directly to me.
Mark
jayadevan m wrote:
>
> Hi
>
> We have one performance(memory) issue in drools-5
>
> Our Scenario
>
> We have 3 entities
>
> Trip - Entity representing details about trip
>
> Driver - Entity for driver , it contain details about driver
>
> Assignments - details about each assignments (one driver may assigned
> to many trip)
>
> The rule is to find ,"Find overlapping between trip assignments"
>
> For Implementing this we take the Trip ,Driver And Assignments
> entities from Data base and put it into working memory
>
> For Small number of records this rule work well ,
>
> But we want to check it against 15000 driver ,331176 assignments and
> 12745 trips
>
> In that case it take huge amount of time for execution (rule firing )
>
>
>
> Rule is
>
> rule "Assignment Check"
>
> when
>
> $creVo: DriverAssignVO($drId: driverId ,$tid: tripId);
>
> $tripAssignment: TripVO(
>
> $tpid: tripId,
>
> $startDtmUtc: startDtmUtc,
>
> $endDtmUtc: endDtmUtc)
>
> and
>
> $trvo: TripVO(
>
> tripId != $tpid,
>
> tripId in ($tid),
>
> ((startDtmUtc >= $startDtmUtc &&
> startDtmUtc <= $endDtmUtc) ||
>
> (endDtmUtc >= $startDtmUtc && endDtmUtc <=
> $endDtmUtc)));
>
> $crvo: DriverAssignVO($drvrId: driverId , driverId ==
> $drId , tripId != $tid, tripId == $tpid)
>
> then
>
> System.out.println("TRIP ID: " + $crvo.getTripId());
>
> end
>
>
>
> thanks and regards
>
17 years
DRL - Accessors that take arguments
by Vidya Chandrasekaran
Hi,
I am fairly new to Drools and am just getting my feet wet with writing
rules.
In my work, I have to integrate drools with classes that do not expose all
properties via getXXX/ isXXX accessor methods but require a call of the form
someMethod("keyvalue"). I have been using the MVEL dialect and do not see a
way to call a function with arguments on the LHS side of a rule either in
the documentation or the mailing list.
In fact, I have been trying something like
rule "rulename"
agenda-group "evaluation"
when
$d: VO( computePrice("key") < 10) from entry-point "Inventory
stream"
then
#
end
This fails with a 'no viable alternative at input '"key"' in rule. Is there
a way this can be accomplished?
Thanks,
Vidya
17 years