This is odd indeed. Are you on Cayenne 3.0?
I am not aware of this issue. All operations involved are constant
time ops regardless of the number of objects previously cached (such
as entry lookup in a HashMap or a list.add(..) operation).
So I may try to run this code in profiler to see why it is slowing
down. If you have access to a profiler and willing to profile it
yourself, this will help a lot of course :-)
Andrus
On Jul 14, 2010, at 2:21 PM, [email protected] wrote:
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