-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Performance issues on Hibernate
PostPosted: Wed May 19, 2004 6:45 pm 
Beginner
Beginner

Joined: Sun May 16, 2004 3:53 pm
Posts: 47
Location: Belo Horizonte, Brazil
Hi,
i know that hibernate (and other o/r mappers) uses methodologies and techniques like lazy instanciation, inteligente update, etc...

This way, is not trivial to measure performace by methods, and the correct way should be by a use case (should give a "real" value).

Anyway, i tried something home wich actually surprised me.
I'm measuring the time a method takes to execute using a DAO and Hibernate.

Basically i have two select methods:
- One via DAO the searches for specific id, returns the whole row from database, builds the complete object and then returns it to client.
- One via Hibernate, tha does pretty much the same. Loads a object correspoding to one row from database, and returns it to client.

Surprinsingly, i get a much better timing with DAO.
-For the DAO method i get something around 0.45 ms
-For the hibernate method i get something around 1.8 ms

This benchmark points that not always Hibernate is good choice, as sometimes when we only fetch data, don't have to many transactions updating diferent tables and don't work with the same object a long time, DAO implementation might be a better choice.

I'd like some comments on what i just said.
I really would like to know other point of view.

Thanks,
ltcmelo


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 6:56 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I'm going to take a wild guess that you are new to Hibernate and have no idea how to set it up correctly for efficient performance. And as I've seen no code and no mappings, I'll continue in that assumption.

There are so many variables to consider here and you have not even given the slightest hint of how any of those played into your "tests".

Let me give you an analogy. Its like me asking you whether I should use EJBs. Then when you say yes, I'll say "but I only want to print out the current date to the console".


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 7:34 pm 
Beginner
Beginner

Joined: Sun May 16, 2004 3:53 pm
Posts: 47
Location: Belo Horizonte, Brazil
You're absolutely rigth, i'm totally new to Hibernate.

But...

- if i'm using such a bad configuration of Hibernate variables, why are they the default ones (cause i'm using Hibernate is it came out of the box)? I think you might agree with me that most people don't like to make big configurations in such kinda software. In my opinion Hibernate should plug into the application as it comes and you may make some little adjustments to get better performance.

- even if i change them, would it make that difference, in other words, would Hibernate get to 0.45 ms i got with DAO?


Steve, i'm posting some code this time, and i really appreciate if you tell me what could've been my bottlenecks (even the better hibernate properties).

Here's the code, in my session fa


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 7:38 pm 
Beginner
Beginner

Joined: Sun May 16, 2004 3:53 pm
Posts: 47
Location: Belo Horizonte, Brazil
Steve, one more comment.
As i said in the first post, i know the is not by measuring the time of one method that i'll get the real data. It'd be a lot better to take the time of a complete part of a use case and then compare (the results can be quite different). This way, we'd see what really Hibernate can do for us.
My point is just that i didn't imagine the for simple queries Hibernate would give a worse result.

Regards,
ltcmelo


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 8:48 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
When I say "set it up correctly for efficient performance", I mean configuring the mapping files. Thats where the majority of performance issue will come from.

Quote:
- if i'm using such a bad configuration of Hibernate variables, why are they the default ones (cause i'm using Hibernate is it came out of the box)? I think you might agree with me that most people don't like to make big configurations in such kinda software. In my opinion Hibernate should plug into the application as it comes and you may make some little adjustments to get better performance.

These mapping files do not come out of the box because they are very specific to your processing. How in the world could Hibernate "plug into an application as it comes"? It needs these mapping files to do its core job.

Quote:
would Hibernate get to 0.45 ms i got with DAO?

OF course not. You'd have to be absurd to think it might in my opinion. This is the quintessential flexibility vs. performance question. As one goes up, the other is going to go down; thats just the nature of the beast. Should you expect it to be that much higher? No. Typically you should expect less than 15% increase.

Quote:
i really appreciate if you tell me what could've been my bottlenecks (even the better hibernate properties).

Like I mentioned above, you did not even include the most important piece of information. Please post the mapping for Person.

But from the code you have posted, I would say that typically performance measurements attempt to isolate the factors they are trying to measure versus the factors they are not. Your tests measurements are also factoring in the amount of time it takes to retreive a JDBC connection during each iteration vs the amount of time needed to build a session during each iteration.

Furthermore, you mention a session facade which to me implies you are retreiving a connection from an app server; that means that jdbcFactory.getConnection() is in all likelihood simply retreiving the same JDBC connection each time, so that would skew your results. You just need to consider whether that is really pertinent to your tests.

Here's a link to a discussion with some general guidelines on doing benchmarks with Hibernate. http://www.hibernate.org/157.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.