mtanneryd / ef-bulk-operations

Bulk operations for Entity Framework 6

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exponential slowdown on parallel executions

Hugibeer opened this issue · comments

Hello.

We are using this library for bulk insert operations in our .NET 4.7 application. We noticed that, when multiple users. So, I typed out a little application which inserts million of entries in a chunks of 4000 items, you can find it in this repo https://github.com/Hugibeer/TannerydSample
I was shocked to see how slow it is when executing bulk insert operation on multiple threads, in https://github.com/Hugibeer/TannerydSample/tree/master/Measurements you can see that, when executing this operaiton in 10 threads, execution per thread is slowed down to 235 seconds, or so. It seems there is something seriously throttling these operations.

I ran 1000 iterations on SQLBulkCopy and SQL procedur inserts, measurements with rudimentary analysis can be read here https://github.com/Hugibeer/TannerydSample/tree/master/AutomatedMeasurements
I am currently running 10 iterations of only ef6 bulk operations and will add those files to the AutomatedMeasurements folder in the repo.

Just to make things clear, this isn't "hate post", I only want to raise an attention to you to these details.

Thank you

For comparison, on test PC I am using, SQLBulkCopy and SQL procedure, on 10 thread parallel executions have average of around 30 seconds, while ef6 bulk operations is at 113 seconds

If you need any input from me, please let me know.
Thank you

It is cleare to me why the library is slower than SqlBulkCopy and SQL procedure approaches, it does two DB orundtrips, one to insert in temp table, the other to insert into real table and hydrate database generated IDs.
I am using slightly older version of library in the repository, I tried updating it, but still got the same performances from it.