Uploaded image for project: 'Service Packs and Hot Fixes'
  1. Service Packs and Hot Fixes
  2. MNT-1377

Performance degrading due to policy invocation

    Details

    • Type: Service Pack Request
    • Status: Closed
    • Resolution: Won't Fix
    • Affects Version/s: No Version
    • Fix Version/s: 2.2.7
    • Component/s: Repository
    • Labels:
      None
    • Bug Priority:
      Category 2
    • ACT Numbers:

      9614

      Description

      We've added many custom aspects (and policy behavior) to our custom content models, and have noticed that performance has been gradually degrading. The slowness is caused by policy invocation. In particular, the OnUpdateProperties policy is the most problematic, because it gets called by many NodeService methods and has been causing a snowball effect when many aspects are added to a node automatically (and each of those aspects set their own dynamic metadata).

      The AuditableAspect was causing OnUpdateProperties to fire quite a bit. It looks like the AuditableAspect is in charge of updating the creator, created, modified, and modifier properties. Currently these properties are updated in a FOR loop, calling nodeService.setProperty four times, resulting in four invocations of OnUpdateProperties:

      public Boolean doWork() throws Exception
      {
      for (QName propertyQName : properties.keySet())

      { Serializable property = properties.get(propertyQName); nodeService.setProperty(nodeRef, propertyQName, property); }

      return Boolean.TRUE;
      }

      I made a simple fix to set these properties in one call instead of four, and this had quite a positive impact on performance, especially when used in conjunction with all our other aspects:

      public Boolean doWork() throws Exception
      {
      // Set all the properties in one nodeService call to avoid multiple calls to onUpdateProperties
      Map<QName, Serializable> allProps = nodeService.getProperties(nodeRef);

      for (QName propertyQName : properties.keySet())

      { Serializable property = properties.get(propertyQName); allProps.put(propertyQName, property); }

      nodeService.setProperties(nodeRef, allProps);
      return Boolean.TRUE;
      }

      Let me know if you see a problem with this change, or have any other suggestions on how we can reduce invocations of OnUpdateProperties.

      We tracked down the source of the policy bottleneck, and it was coming from the org.alfresco.repo.rule.ruletrigger.OnPropertyUpdateRuleTrigger and OnCreateNodeRuleTrigger classes. We had propagating rules defined on Company Home, and so these checks were taking an extremely long time to run (300-400 ms per call). We switched our rules to direct policy, and everything is running much faster.

        Attachments

          Structure

            Activity

              People

              • Assignee:
                closedissues Closed Issues
                Reporter:
                hdann Helen Dann (Inactive)
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Structure Helper Panel