ObjectDB ObjectDB

Java 6/7 Performance Comparison

#1

Hey,

I've been using ObjectDB for a small scale home project to gain some familiarity before proposing it in a commercial project at work.

What I've noticed though is that when using objectdb in embedded mode based on the console tutorial, there seems to be a bit of a performance gap running the same code between Java 6 & 7

Tracing it through I can see the bottle neck seems to be at the creation of the entity manager and I was wondering if there are any additional configuration options I may have missed while running under java 7.

long start = System.currentTimeMillis();
EntityManagerFactory emf =
            Persistence.createEntityManagerFactory("$objectdb/db/points.odb");
EntityManager em = emf.createEntityManager();
long end = System.currentTimeMillis();

System.out.printf("Load Time %s ms\n", (end-start));

Java 1.7.0_51-b13 (MacOS X)

Output: Load Time 30629 ms

Java 1.6.0_65 (MacOS X)

Output: Load Time 329 ms

Also see a similar execution time when closing the entity manager, however any operations once loaded appear to perform comparably.

I've tried running this on a brand new machine as well as my main dev machine and see similar results, both with the default configuration when downloaded and then again after adjusting the objectdb.conf to grant more memory/threads to applications but have not noticed any differences in performance so looking for some advice to see if there is something I have missed or this should be all I have to do to run under Java 7.

Thanks

- Andrew

edit
delete
#2

Opening an EntityManagerFactory and an EntityManager should never take 30 seconds. Most ObjectDB users use Java 7, so obviously it is not just Java 7 but also something else.

Could you please provide a test case that demonstrates this?

ObjectDB Support
edit
delete
#3

Thanks, I agree it has to be something other than java 7 but having trouble narrowing it down.

Attached is a test case I've been running which is just based on the tutorial and the output for it.
I've packaged the class into a jar file on its own run this from the terminal (to rule out any issues with eclipse)

andrews-mbp:Desktop aduffy$ java -version

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)

Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
andrews-mbp:Desktop aduffy$ java -jar JPADemo.jar -cp JPADemo_lib/objectdb.jar
Factory build in 30393 ms
Total Points: 3000
Average X: 499.5
Factory closed in 30082 ms
andrews-mbp:Desktop aduffy$ /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -version

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)

Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
andrews-mbp:Desktop aduffy$ /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -jar JPADemo.jar JPADemo_lib/objectdb.jar
Factory build in 314 ms
Total Points: 4000
Average X: 499.5
Factory closed in 29 ms
andrews-mbp:Desktop aduffy$

Have tried this on 2 machines with similar results, one has never had objectdb before, but oddly enough, tried it on a 3rd this morning which has never had java on it before and didn't come across this issue with the test case, so not sure where to go with this one now. Not sure if it helps but suspect the same issue occurs when running ObjectDB Explorer as there is roughly a 30 second delay each time I open the jar/switch connections while running with java 7.

 

edit
delete
#4

Should have mentioned, have been using 2.5.4_04, but have tried all the versions back to 2.5.3

edit
delete
#5

We couldn't reproduce the problem in our environment using your example with Java 7.

Could you please run your program with a profiler (e.g. Java VisualVM) and provide profiling info?

ObjectDB Support
edit
delete
#6

Attached is the CPU and Memory profile outputs across 2 runs of the test case.

I had to change the test case slightly to include a modal JDialog which would stop the application so I could attach the profiler, aside from that test case remained unchanged.

edit
delete
#7

Unfortunately there is no much information in these profile files. It is unclear which thread (main? AWT-EventQueue?) performs the database operations, and no ObjectDB operations are recorded.

It would be be better to use a simple console application, and profiling of com.objectdb.* classes should be added, in order to collect ObjectDB related profile information.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.