🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Collect very slow
(Created page with "I have at some occasions been struck by extremely bad performance when it comes to the ocl Collect operator. After debugging I have concluded that the expression used was wro...")
 
No edit summary
Line 1: Line 1:
I have at some occasions been struck by extremely bad performance when it comes to the ocl Collect operator.
I have at occasions been struck by extremely bad performance when it comes to the ocl Collect operator.


After debugging I have concluded that the expression used was wrong compared with by intended usage
After debugging I have concluded that the expression used was wrong compared to my intended usage and need.
 
Consider this expression:
Sequence{0..7000}->collect(a| vCollectionDetails.add(Detail.Create))
My intention is to create 7000 Detail-objects and put them in the variable vCollectionDetails that has type Collection(Detail)
 
But this expression is very (extremly) slow.
 
The main reason for the slowliness is that collect actually build a result of all the results of the inner expression. In our case this is a List of 1 detail,List of 2 details,List of 3 details...List of 6990 details etc. And this is a heavy operation as 7000 thousand lists must be created and filled with 7000*7000/2 objects - and I am not even interested in that result - I only used the Collect operator as a convenient way to act on each.
 
If I avoid to return the list - and instead return something simple like this:
Sequence{0..7000}->collect(a| vCollectionDetails.add(Detail.Create);0)
In this case the collect operator returns 1 list with 7000 zeros - very much faster than 24 million references to Detail objects.

Revision as of 11:59, 18 September 2018

This page was created by Hans.karlsen on 2018-09-18. Last edited by Stephanie on 2025-02-11.

I have at occasions been struck by extremely bad performance when it comes to the ocl Collect operator.

After debugging I have concluded that the expression used was wrong compared to my intended usage and need.

Consider this expression:

Sequence{0..7000}->collect(a| vCollectionDetails.add(Detail.Create))

My intention is to create 7000 Detail-objects and put them in the variable vCollectionDetails that has type Collection(Detail)

But this expression is very (extremly) slow.

The main reason for the slowliness is that collect actually build a result of all the results of the inner expression. In our case this is a List of 1 detail,List of 2 details,List of 3 details...List of 6990 details etc. And this is a heavy operation as 7000 thousand lists must be created and filled with 7000*7000/2 objects - and I am not even interested in that result - I only used the Collect operator as a convenient way to act on each.

If I avoid to return the list - and instead return something simple like this:

Sequence{0..7000}->collect(a| vCollectionDetails.add(Detail.Create);0)

In this case the collect operator returns 1 list with 7000 zeros - very much faster than 24 million references to Detail objects.

MDriven Chat

How would you like to chat today?

Setting up your conversation…

This may take a few moments