Geoffrey,
I just committed some code that I believe fixed the infinite loop
problem. Would you please take a look if it works for you? I will take a
look at the other problems now... thanks for reporting that.
Regarding the performance, the main benefit of true modify is not a
straight gain on performance, but the reduction of the garbage collection
stress. Just to explain, the code now is actually more complex, but the idea
is that the algorithm pays off by instantiating a lot less objects now,
specially LeftTuples. I would not be surprised if the 4% gain you see is due
to less object instantiation+garbage collection work. This is obviously
dependent on the use case, but one really interesting statistic to see would
be if you can profile how many instances of LeftTuple were created with the
previous algorithm compared to now.
Having said that, there are some performance improvements for specific
cases, like on accumulate that before would frequently clone lists of tuples
and iterate and now it avoids both the cloning and the iteration on specific
cases. For those cases, we expect gains of 30% on the node, but that is just
the node, not the whole kbase.
Also, as you mentioned, true modify opens the door for several other
optimizations that we will work on as soon as it is stable again.
Thanks,
Edson
2010/3/7 Geoffrey De Smet <ge0ffrey.spam(a)gmail.com>
Found another issue with the true modify changes: 3 of my examples
don't
work (NQueens, Travelingtournament, Examination), due to distinct causes.
PatientAdmissionScheduling does work and it's about 4% faster on first
sight.
It's a linear improvement, not an exponential improvement.
Nothing world shocking (yet), but every little bit helps :)
Edson and Mark believe that true modify allows for new optimization,
which I believe might be an exponential improvement.
Once examination works I'll test if I can remove the TMS workaround I
needed before.
This will be a huge performance boost, but only for that specific example.
Here's the bug list:
1) Infinite loop in
org.drools.core.util.LeftTupleList.get(LeftTupleList.java:102)
2) NPE in
org.drools.core.util.RightTupleList.matches(RightTupleList.java:190)
because this.first is null in
return this.hashCode == tupleHashCode && this.index.equal(
this.first.getFactHandle().getObject(),
tuple );
3) NPE in
org.drools.reteoo.SingleLeftTupleSinkAdapter#propagateModifyChildLeftTuple,
line 198:
the leftTuple or the sink is null
childLeftTuple.getLeftTupleSink().modifyLeftTuple( childLeftTuple,
context,
workingMemory );
Here are the stacktraces:
1)
1.
To run:
2.
module: drools-planner-examples
3.
main class:
org.drools.planner.examples.examination.app.ExaminationBenchmarkApp
4.
VM params: -Xms256m -Xmx512m -server
5.
program params: short
6.
working dir:
/home/ge0ffrey/projects/jboss/drools/drools-planner/drools-planner-examples
7.
8.
9.
More logging? open log4j-benchmark.xml and turn on debug logging
for org.drools.planner
10.
11.
12.
2010-03-03 19:47:34,625 [main] INFO Solving with random seed (0).
13.
2010-03-03 19:47:34,626 [main] DEBUG Solution is already initialized.
14.
2010-03-03 19:47:34,752 [main] INFO Initialization time spend
(129) for score (0hard/-8154soft). Updating best solution and best
score.
15.
2010-03-03 19:47:34,948 [main] DEBUG Move (489 {D180|S47} @ 17
{D210} + 4 {C77} => 25 {D210}) with score (-47hard/-8190soft) and
acceptChance (1.0).
16.
2010-03-03 19:47:34,972 [main] DEBUG Move (373 {D180|S157} @
23 {D210} + 0 {C260} => 16 {D210}) with score (-158hard/-8219soft)
and acceptChance (1.0).
17.
2010-03-03 19:47:34,985 [main] DEBUG Move (530 {D120|S152} @
16 {D210} + 0 {C260} => 39 {D210}) with score (-153hard/-8481soft)
and acceptChance (1.0).
18.
2010-03-03 19:47:35,001 [main] DEBUG Move (132 {D120|S61} @ 53
{D210} + 5 {C65} => 24 {D210}) with score (-64hard/-8243soft) and
acceptChance (1.0).
19.
2010-03-03 19:47:35,011 [main] DEBUG Move (553 {D180|S169} @
51 {D210} + 0 {C260} => 37 {D210}) with score (-168hard/-8323soft)
and acceptChance (1.0).
20.
2010-03-03 19:52:03
21.
Full thread dump Java HotSpot(TM) Server VM (14.2-b01 mixed mode):
22.
23.
...
24.
25.
"main" prio=10 tid=0x08b2b800 nid=0x1104 runnable [0xb6aa6000]
26.
java.lang.Thread.State: RUNNABLE
27.
at
org.drools.common.DefaultFactHandle.hashCode(DefaultFactHandle.java:136)
28.
at org.drools.reteoo.LeftTuple.hashCode(LeftTuple.java:445)
29.
at org.drools.reteoo.LeftTuple.equals(LeftTuple.java:461)
30.
at
org.drools.core.util.LeftTupleList.get(LeftTupleList.java:102)
31.
at
org.drools.core.util.LeftTupleList.contains(LeftTupleList.java:96)
32.
at
org.drools.reteoo.EvalConditionNode.modifyLeftTuple(EvalConditionNode.java:235)
33.
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:209)
34.
at
org.drools.reteoo.JoinNode.modifyRightTuple(JoinNode.java:221)
35.
at org.drools.reteoo.BetaNode.modifyObject(BetaNode.java:317)
36.
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:444)
37.
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:412)
38.
at
org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:262)
39.
at
org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:174)
40.
at
org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1392)
41.
at
org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1288)
42.
at
org.drools.planner.examples.examination.solver.move.ExaminationMoveHelper.movePeriod(ExaminationMoveHelper.java:17)
43.
at
org.drools.planner.examples.examination.solver.move.PeriodChangeMove.doMove(PeriodChangeMove.java:37)
44.
at
org.drools.planner.core.localsearch.decider.DefaultDecider.doMove(DefaultDecider.java:117)
45.
at
org.drools.planner.core.localsearch.decider.DefaultDecider.decideNextStep(DefaultDecider.java:95)
46.
at
org.drools.planner.core.localsearch.DefaultLocalSearchSolver.solveImplementation(DefaultLocalSearchSolver.java:105)
47.
at
org.drools.planner.core.AbstractSolver.solve(AbstractSolver.java:41)
48.
at
org.drools.planner.benchmark.SolverBenchmarkSuite.benchmark(SolverBenchmarkSuite.java:196)
49.
at
org.drools.planner.benchmark.XmlSolverBenchmarker.benchmark(XmlSolverBenchmarker.java:72)
50.
at
org.drools.planner.examples.common.app.CommonBenchmarkApp.process(CommonBenchmarkApp.java:25)
51.
at
org.drools.planner.examples.examination.app.ExaminationBenchmarkApp.main(ExaminationBenchmarkApp.java:27)
52.
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
53.
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
54.
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
55.
at java.lang.reflect.Method.invoke(Method.java:597)
56.
at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
2) Run NQueensSmokeTest
java.lang.NullPointerException
at org.drools.core.util.RightTupleList.matches(RightTupleList.java:190)
at
org.drools.core.util.RightTupleIndexHashTable.get(RightTupleIndexHashTable.java:301)
at
org.drools.core.util.RightTupleIndexHashTable.getFirst(RightTupleIndexHashTable.java:87)
at org.drools.reteoo.JoinNode.modifyLeftTuple(JoinNode.java:260)
at org.drools.reteoo.BetaNode.modifyLeftTuple(BetaNode.java:336)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateModifyObject(CompositeLeftTupleSinkAdapter.java:204)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateModifyObject(CompositeLeftTupleSinkAdapter.java:219)
at
org.drools.reteoo.LeftInputAdapterNode.modifyObject(LeftInputAdapterNode.java:154)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:444)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:412)
at
org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:262)
at
org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:174)
at
org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1392)
at
org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1288)
at
org.drools.planner.examples.nqueens.solver.move.YChangeMove.doMove(YChangeMove.java:38)
at
org.drools.planner.core.localsearch.decider.DefaultDecider.doMove(DefaultDecider.java:119)
at
org.drools.planner.core.localsearch.decider.DefaultDecider.decideNextStep(DefaultDecider.java:95)
at
org.drools.planner.core.localsearch.DefaultLocalSearchSolver.solveImplementation(DefaultLocalSearchSolver.java:105)
at org.drools.planner.core.AbstractSolver.solve(AbstractSolver.java:41)
at
org.drools.planner.examples.nqueens.NQueensSmokeTest.testSmoke(NQueensSmokeTest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:108)
at
com.intellij.junit3.JUnit3IdeaTestRunner.startRunnerWithArgs(JUnit3IdeaTestRunner.java:42)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:165)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
3) Run SmartTravelingTournamentBenchmarkApp
Exception in thread "main" java.lang.NullPointerException
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:198)
at org.drools.reteoo.JoinNode.modifyLeftTuple(JoinNode.java:304)
at org.drools.reteoo.BetaNode.modifyLeftTuple(BetaNode.java:336)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateModifyObject(CompositeLeftTupleSinkAdapter.java:204)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateModifyObject(CompositeLeftTupleSinkAdapter.java:219)
at
org.drools.reteoo.LeftInputAdapterNode.modifyObject(LeftInputAdapterNode.java:154)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:444)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:412)
at
org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:262)
at
org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:174)
at
org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1392)
at
org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1288)
at
org.drools.planner.examples.travelingtournament.solver.smart.move.MultipleMatchListRotateMove.rotateList(MultipleMatchListRotateMove.java:59)
at
org.drools.planner.examples.travelingtournament.solver.smart.move.MultipleMatchListRotateMove.doMove(MultipleMatchListRotateMove.java:44)
at
org.drools.planner.core.localsearch.decider.DefaultDecider.doMove(DefaultDecider.java:117)
at
org.drools.planner.core.localsearch.decider.DefaultDecider.decideNextStep(DefaultDecider.java:95)
at
org.drools.planner.core.localsearch.DefaultLocalSearchSolver.solveImplementation(DefaultLocalSearchSolver.java:105)
at org.drools.planner.core.AbstractSolver.solve(AbstractSolver.java:41)
at
org.drools.planner.benchmark.SolverBenchmarkSuite.benchmark(SolverBenchmarkSuite.java:196)
at
org.drools.planner.benchmark.XmlSolverBenchmarker.benchmark(XmlSolverBenchmarker.java:72)
at
org.drools.planner.examples.common.app.CommonBenchmarkApp.process(CommonBenchmarkApp.java:25)
at
org.drools.planner.examples.travelingtournament.app.smart.SmartTravelingTournamentBenchmarkApp.main(SmartTravelingTournamentBenchmarkApp.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
--
With kind regards,
Geoffrey De Smet
_______________________________________________
rules-dev mailing list
rules-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @
www.jboss.com