Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-1468

Commit performance degradation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0
    • 3.0.1
    • Core Library
    • None

    Description

      While developing an application using Cayenne I noticed that the
      performance of DataContext.commitChanges() degrades with the number of
      commits done.

      To be more specific, I have a model with two entities: Result and
      ResultStream, with a many to one relation from Result to ResultStream.

      The test I do is simple: I generate a lot of Result objects, all linked to
      the same ResultStream and I call commit after each Result added to the
      DataContext and measure the time it takes to perform the commit. I notice
      that this time grows fairly linear. Of course, the growth is noticeably
      after generating many results

      Here is the source code of the test:

      public class Main {

      public static void main(String[] args) {
      DataContext dc = DataContext.createDataContext();

      final int stepSize = 500;
      final int nbSteps = 50;

      SelectQuery sq = new SelectQuery(ResultStream.class);

      ResultStream rs = (ResultStream) dc.performQuery(sq).get(0);

      StopWatch sw = new StopWatch();
      sw.start();

      for (int i = 1; i <= nbSteps * stepSize; ++i) {
      Result t = new Result();
      t.setValue;
      t.setResultStream(rs);

      dc.commitChanges();

      if (i % stepSize == 0)

      { sw.stop(); System.out.printf("%6d, %s, %5d\n", i, DurationFormatUtils.formatDurationHMS(sw.getTime()), sw.getTime()); sw.reset(); sw.start(); }

      }
      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            cosmin.marian Cosmin Marian
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: