Parallel evaluation

I am running some processing in parallel that includes api calls.The result with then populate an interface attended by a user.

I have tried both a!forEach and MNI but for both the performance is not as expected.

By looking at the performance tab in the expression rule, it is clear that the items in the array are running sequentially and not in parallel,

as the total time for the expression rule is the sum of every iteration. As a test I tried to put only a GET api call in the foreach loop and the result is the same.

This is not what I was expecting, is there anything that can be done to enforce the threads to run in parallel to optimize the performance?

  Discussion posts and replies are publicly visible

Parents Reply
  • I somehow stumbled on a solution.

    The original code was:

    a!forEach(
      items: ri!ofscSlots,
      expression: rule!FF_processOFSCSlotsBridge(
        ofscSlot: fv!item,
        activityType: ri!activityType,
        postcode: ri!postcode,
        duration: ri!duration,
        products: ri!products
      )
    )

    Bizarrely the (ugly) code below trigger the parallel evaluation

    a!localVariables(
      local!numberSlots: length( ri!ofscSlots),
      {
        if(1<=local!numberSlots,
           rule!FF_processOFSCSlotsBridge(
             ofscSlot: ri!ofscSlots[1],
             activityType: ri!activityType,
             postcode: ri!postcode,
             duration: ri!duration,
             products: ri!products
           ),
           {}
           ),
           if(2<=local!numberSlots,
           rule!FF_processOFSCSlotsBridge(
             ofscSlot: ri!ofscSlots[2],
             activityType: ri!activityType,
             postcode: ri!postcode,
             duration: ri!duration,
             products: ri!products
           ),
           {}
           ),
          ---- And so on ------  

    The expression rule has multiple api calls and some relatively simple data transformation.

    Really strange

Children