Improve materialization performance (for simple Linq query, may reduce 50%+ time)
As currently when constructing entities from a linq query, it calls Delegate class's dynamicInvoke, which is believe to be slow.
Improvement could be simple:
See attached file for sample of improving constructing items, for constructing list, same way could be applied.
Please be aware if you use any profiler tool to profile this, may not be able clearly identify the problem because transformer is called less time than retrieving row/column data from idatareader, but each call took longer time. Although in real life, transformer took more than half of time, but because of wall time costed by profiler, when profiling it only took less than 20% of time.
This is the quick fix I can find so far. But I believe the code in for retrieving row/column value from datareader can be improved as well.
for example in Type/AbstractStringType.cs, currently it uses unnessary converter.convertoxxx() method, which is slow. And after unnessary convert, it box the value to object again. It could be simplfied to rs.GetString(index). Same logic could apply to other types. Also, if you could flatten the struct when retrieving values, could help improve performance a lot.
Fixed in master 601566e76416a22c335c28923d39593412881ae6
I've did some test.
For a simple entity, has 1 int key column 2 string columns. And it's the
only table in the database.
It has 200001 rows. Testing platform is MSSQL express, win 7 i5 4gb memory.
Before improvement it tooks 1.2 seconds retrieving all entities ( select by
anonymous type and status less session).
After change it tooks 0.5 to 0.6 seconds.
On Tue, Jan 22, 2013 at 8:34 PM, Alexander I. Zaytsev (JIRA) <
Can you please make performance tests?