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.  [ 6 posts ] 
Author Message
 Post subject: NHibernate Collection Performance Using Generics is BAD !
PostPosted: Thu Jul 26, 2007 6:41 am 
Beginner
Beginner

Joined: Fri May 25, 2007 5:55 am
Posts: 26
I am using NHibernate 1.2.0 GA.

This is less of a question and more my view on performance using Generic Collections in NHibernate.

I am running performance tests at the moment.

I have an table of objects in the database called CARs for instance.

If I do a criteria query on them using generics it takes 68 seconds to retrieve 100,000 rows.

criteria.List<Car>();

If I simply remove the Generics and do this.

criterial.List();

It now takes 42 seconds. The object coming back as around 42 columns so its big enough. The Query itself is very fast, it is doing an outer joing on one tabe that has a one-to-zero-or-one mapping. Its the marshalling that takes most of the time. Logging is OFF by the way.

This is a dramatic decrese in time and now it is actually nearly as fast as ADO.NET direct. I removed the generic collections for ADO.NET (This is mapping code that I wrote myself) and there was no performance increase.

This leads me to believe that whatever way NHibernate is using generics is not great or needs to be optimized further.

Anyone got anything to add to this. Are there further ways of improving performance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 9:08 am 
Beginner
Beginner

Joined: Mon Mar 06, 2006 2:19 pm
Posts: 42
Location: Belo Horizonte, Brazil
Maybe you can use a profiler. What do you think?


Top
 Profile  
 
 Post subject: Performace
PostPosted: Thu Jul 26, 2007 9:18 am 
Beginner
Beginner

Joined: Fri May 25, 2007 5:55 am
Posts: 26
In this case I would be performing profiling on NHibernate code. I cant optimize that.

I need ideas and ways to improve how NHibernate Marshalls objects from the database.

IQuery : Has roughly the same performance.
Enumerable : Has much worse performance.

I could use the second level cache and the query cache but I am just interested in the initial hit on the database and getting that data marshalled.

Once I am happy with its performance I will then look at the second level chache.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 11:03 am 
Beginner
Beginner

Joined: Mon Mar 06, 2006 2:19 pm
Posts: 42
Location: Belo Horizonte, Brazil
Quote:
In this case I would be performing profiling on NHibernate code. I cant optimize that.


You can, if it's not optimized yet (I believe it is) and if you know how to. But even if you can't or don't want to, if you find something relevant NHibernate team could do this in the future.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 11:34 am 
Beginner
Beginner

Joined: Tue Jul 19, 2005 11:21 am
Posts: 23
Location: erie, pa
Looking at the source code... the implementations of List() and List<T>() are identical other than one constructs an ArrayList and the other a List<T>. Both methods delegate to the same method which takes an IList to fill. Maybe there's performance hit to adding items to a List<T> via its IList interface....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 11:41 am 
Beginner
Beginner

Joined: Fri May 25, 2007 5:55 am
Posts: 26
Actually. For some reason, on changing it back to List<T>() the performance gain I had earlier is not going away.

Seems like maybe this performance gain may be down to something else. I am going to investigate further.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.