Re: Commit performance degradation

From: cosmin.maria..odium-it.com
Date: Wed Jul 14 2010 - 11:21:15 UTC

  • Next message: Andrus Adamchik: "Re: Commit performance degradation"

    Sorry,

    The attached file was not uploaded.
    Here it is:

    package insert;

    import org.apache.cayenne.access.DataContext;
    import org.apache.cayenne.query.SelectQuery;
    import org.apache.commons.lang.time.DurationFormatUtils;
    import org.apache.commons.lang.time.StopWatch;

    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(i);
                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();
                }
            }
        }
    }

    > Hello,
    >
    > 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.
    >
    > Attached is the test source.
    >
    > If I don't make the link between result and resultStream, the performance
    > is not degrading
    >
    > Could you please help me with some advice?
    > Is this a known issue, can it be fixed by tweaking cayenne?
    >
    > Many thanks,
    > Cosmin
    >
    >
    >
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Jul 14 2010 - 11:21:47 UTC