Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-923

Performance problem, MapTransaction.findNode() called excessively

    XMLWordPrintable

Details

    Description

      I found that the more and more nodes I added to a repository, the longer it took to perform a javax.jcr.Session.save(). Profiling javax.jcr.Session.save(), I found that a large amount of CPU time was spent in FederatedRequest.await(). The await is done using concurrent wait methods which can be CPU intensive if they're held for long periods of time. The cause of that was that the threads performing the save were taking more and more time to save and, hence, await() was taking longer and longer to complete.

      Profiling further, from org.modeshape.graph.request.processor.RequestProcessor.process(org.modeshape.graph.request.Request) it appears that at least part of the culprit is excessive calls to MapTransaction.findNode(). What I found was that each session save was invoking MapTransaction.findNode() n + 10300 times where n == the previous number of calls to session.save().

      The test I was running basically looks like this:

      Node root = session.getRootNode();
      for(int i = 0; i < 50000; ++i) {
      Node entry = root.addNode("e_" + i, "entry:Entry");
      entry.setProperty("entry:EVENTID", Integer.toString);
      entry.setProperty("entry:USERNAME", users[i % users.length]);
      entry.setProperty("entry:OBJECTNAME", objects[i % objects.length]);
      entry.setProperty("entry:SERVERTIME", Calendar.getInstance());
      if (i % 100 == 0)

      { System.out.println("SAVED!!! (" + i + ") - [" + new SimpleDateFormat("HH:mm:ss.SSSZ").format(new Date()) + "]"); long begin = System.currentTimeMillis(); session.save(); long diff = System.currentTimeMillis() - begin; System.out.println("==> Save took " + diff + " milliseconds."); }

      }

      it's a very shallow hierarchy, every node is a child of the root node.

      I will provide a test case with a patch that shows the number of invocations of findNode increasing with each save, might not be until this weekend though.

      Attachments

        1. findNodeInvocations.diff
          1 kB
        2. MODE-923.patch
          4 kB
        3. modeshape-infinispan.zip
          11 kB
        4. modeshape-infinispan.zip
          15 kB

        Activity

          People

            bcarothers_jira Brian Carothers (Inactive)
            craigching_jira Craig Ching (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: