[rules-users] Object size affect on session insertion performance

Wolfgang Laun wolfgang.laun at gmail.com
Sat Feb 22 02:34:07 EST 2014


The durations you quote are hard to believe unless you run a very old
computer ;-)

I can insert 5000 Objects (3 fields) into a session with this single
"collecting" rule
in 0.28 seconds, which is several orders of magnitude faster than your 35 sec.

Are there other rules around? Some that refer only to ComplexClass?

-W

On 22/02/2014, mikerod <mjr4184 at gmail.com> wrote:
> Does the size of objects inserted into the session as facts directly affect
> performance?
>
> I have ran some very simple tests, with a kb with 1 rule that
> accumulated/collected over all facts in working memory of a type.
>
> If I have a really simple/small class, say SimpleClass
>
> It looks like:
>
> ```
> rule "collecting"
> 	when
> 	$res : List() from
> 			accumulate( $s : SimpleClass(),
> 				init( List l = new ArrayList(); ),
> 				action( l.add($s); ),
> 				result( l ))
> 	then
> 	System.out.println("Done");
> end
> ```
>
> If I have a more complex class that will result in deeply nested objects,
> say ComplexClass
> It looks like:
>
> ```
> rule "collecting"
> 	when
> 	$res : List() from
> 			accumulate( $s : ComplexClass(), // this is the only difference from
> above
> 				init( List l = new ArrayList(); ),
> 				action( l.add($s); ),
> 				result( l ))
> 	then
> 	System.out.println("Done");
> end
>
> Now my Java test is just a simple one that puts a timer before and after
> insert like:
>
> ```
>
> // initialize kb and session as usual
>
> // make N number of objects to insert of type SimpleClass or ComplexClass;
> depending on test run
> // store them in local variable cs
>
>         final long start = System.nanoTime();
>         for (final SimpleClass c : cs) { // This would be ComplexClass when
> comparing
>             ksession.insert(c);
>         }
>         final double end = ((System.nanoTime() - start) / 1000000.0);
>
>
>         final int firedRules = ksession.fireAllRules(); // not really
> needed
> here
>
> ```
>
> What I notice from these tests, is that for something like N=5000 of
> SimpleClass inserted into the session runs quick, say something like 35
> sec.
>
> However, for the same N=5000 of ComplexClass inserted into the session, the
> time jumps to something like 148 sec.
>
> I haven't done exhaustive performance testing around this, but I am seeing
> this in more complex scenarios as well.
>  I know that heap space (maybe perm space) play a role in this, but I have
> monitored my JVM processes  during execution and there is no lack of
> available heap space and my machine has a lot of resources available still
> in both SimpleClass and ComplexClass scenarios.
>
> I am trying to understand if the actual size of an object inserted into the
> session has an affect on its overall performance.
> This may be a trivial question and I'm just overlooking something, but I'd
> appreciate any advice and feedback on this subject.  I have not
> successfully
> been able to find any resources on the internet where this has been
> explicitly asked to base any thought off of.  I also have read up some on
> Rete (and variations e.g. Drools), but I don't see how the size of the
> objects inserted as facts applies to the insert performance.
>
> Thanks!
>
>
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Object-size-affect-on-session-insertion-performance-tp4028244.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list