473,326 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Release is slower than debug... What's happening?

Hi,
I have a windows service that only loads a CSV file and import it's data
using SqlBulkCopy in a newly created Sql Server 2005 table using 25000 rows
batches.

If I build the service in debug mode and run it, I get descent performances.
If I build it in release mode, I would expect it to at least stay as fast
and maybe be faster, but I actually lose performance. I lose about 10%
performance.

How can this happen?

Here's what could be involved :
- SqlBulkCopy Class a IDataReader implementation as a source which
performance has been verified.
- <SqlDbTypes>.Parse(...)
- Array indexing
- Boxing and Unboxing of objects
- Generic classes (List, Dictionary, Hashtable) search by key

Thanks

ThunderMusic
Jun 1 '07 #1
11 3105
oups
- SqlBulkCopy Class a IDataReader implementation as a source which
performance has been verified.

should read

- SqlBulkCopy Class using a IDataReader implementation as a source which
performance has been verified.
"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:OR**************@TK2MSFTNGP05.phx.gbl...
Hi,
I have a windows service that only loads a CSV file and import it's data
using SqlBulkCopy in a newly created Sql Server 2005 table using 25000
rows batches.

If I build the service in debug mode and run it, I get descent
performances. If I build it in release mode, I would expect it to at least
stay as fast and maybe be faster, but I actually lose performance. I lose
about 10% performance.

How can this happen?

Here's what could be involved :
- SqlBulkCopy Class a IDataReader implementation as a source which
performance has been verified.
- <SqlDbTypes>.Parse(...)
- Array indexing
- Boxing and Unboxing of objects
- Generic classes (List, Dictionary, Hashtable) search by key

Thanks

ThunderMusic

Jun 1 '07 #2

"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:OR**************@TK2MSFTNGP05.phx.gbl...
Hi,
I have a windows service that only loads a CSV file and import it's data
using SqlBulkCopy in a newly created Sql Server 2005 table using 25000
rows batches.

If I build the service in debug mode and run it, I get descent
performances. If I build it in release mode, I would expect it to at least
stay as fast and maybe be faster, but I actually lose performance. I lose
about 10% performance.

How can this happen?
Are you measuring first run performance, or steady state?

The first run requires that the JIT compiler be run, and in release mode the
JIT has to look for optimizations, hence taking longer. After the code is
compiled, however, the incremental cost of rerunning it is usually greatly
reduced by the optimizations.
>
Here's what could be involved :
- SqlBulkCopy Class a IDataReader implementation as a source which
performance has been verified.
- <SqlDbTypes>.Parse(...)
- Array indexing
- Boxing and Unboxing of objects
- Generic classes (List, Dictionary, Hashtable) search by key

Thanks

ThunderMusic

Jun 1 '07 #3
Even after many runs, it's still slower.

"Ben Voigt [C++ MVP]" <rb*@nospam.nospamwrote in message
news:u3**************@TK2MSFTNGP06.phx.gbl...
>
"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:OR**************@TK2MSFTNGP05.phx.gbl...
>Hi,
I have a windows service that only loads a CSV file and import it's data
using SqlBulkCopy in a newly created Sql Server 2005 table using 25000
rows batches.

If I build the service in debug mode and run it, I get descent
performances. If I build it in release mode, I would expect it to at
least stay as fast and maybe be faster, but I actually lose performance.
I lose about 10% performance.

How can this happen?

Are you measuring first run performance, or steady state?

The first run requires that the JIT compiler be run, and in release mode
the JIT has to look for optimizations, hence taking longer. After the
code is compiled, however, the incremental cost of rerunning it is usually
greatly reduced by the optimizations.
>>
Here's what could be involved :
- SqlBulkCopy Class a IDataReader implementation as a source which
performance has been verified.
- <SqlDbTypes>.Parse(...)
- Array indexing
- Boxing and Unboxing of objects
- Generic classes (List, Dictionary, Hashtable) search by key

Thanks

ThunderMusic


Jun 1 '07 #4
ThunderMusic,
This simply "does not compute". Are you actually installing this windows
service after it has been built in a debug build configuration? And you are
comparing the performance against a different Windows Service installation
that was done with a release build?

What I'd do (unless you want to get into some heavy-duty profiling) is use
the Stopwatch class to take some start / finish timings around critical
operations that occur when your service runs, and write the results as
appended lines to a text file.

Examining this, if you have instrumented it properly, should give more
insight.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"ThunderMusic" wrote:
Hi,
I have a windows service that only loads a CSV file and import it's data
using SqlBulkCopy in a newly created Sql Server 2005 table using 25000 rows
batches.

If I build the service in debug mode and run it, I get descent performances.
If I build it in release mode, I would expect it to at least stay as fast
and maybe be faster, but I actually lose performance. I lose about 10%
performance.

How can this happen?

Here's what could be involved :
- SqlBulkCopy Class a IDataReader implementation as a source which
performance has been verified.
- <SqlDbTypes>.Parse(...)
- Array indexing
- Boxing and Unboxing of objects
- Generic classes (List, Dictionary, Hashtable) search by key

Thanks

ThunderMusic
Jun 1 '07 #5
On Jun 1, 10:33 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
ThunderMusic,
This simply "does not compute". Are you actually installing this windows
service after it has been built in a debug build configuration? And you are
comparing the performance against a different Windows Service installation
that was done with a release build?

What I'd do (unless you want to get into some heavy-duty profiling) is use
the Stopwatch class to take some start / finish timings around critical
operations that occur when your service runs, and write the results as
appended lines to a text file.

Examining this, if you have instrumented it properly, should give more
insight.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

"ThunderMusic" wrote:
Hi,
I have a windows service that only loads a CSV file and import it's data
using SqlBulkCopy in a newly created Sql Server 2005 table using 25000 rows
batches.
If I build the service in debug mode and run it, I get descent performances.
If I build it in release mode, I would expect it to at least stay as fast
and maybe be faster, but I actually lose performance. I lose about 10%
performance.
How can this happen?
Here's what could be involved :
- SqlBulkCopy Class a IDataReader implementation as a source which
performance has been verified.
- <SqlDbTypes>.Parse(...)
- Array indexing
- Boxing and Unboxing of objects
- Generic classes (List, Dictionary, Hashtable) search by key
Thanks
ThunderMusic- Hide quoted text -

- Show quoted text -
I was using same kind of functionality, but in the reverse way,
loading data from SQL to CRM Server and then to MSMQ. Again from queue
to a CSV file. The performance is considerably better when I built the
windows service in release mode. I've found it out using the
aforementioned Stopwatch class. I'd venture to suggest the same.

Jun 1 '07 #6
Hi,
Thanks for the answers...

1) Yes, it's the same service I'm testing, in debug, then in release (or in
release then in debug, no importance, I get the same results) and always on
the same computer.
2) The thing is, We are already logging when the application reach an
important point (with Timestamps). So using Stopwatch here will only add
overhead to the process. Actually, we are taking a 4000000 rows CSV and copy
it to a SQL Table by taking care the datatypes are good. So we optimized our
process and managed to get a good performance (by replacing most of the
generics by native arrays, using temporary variables instead of always
getting the current value from the file reader, et al.) maybe we optimized
"too much" and the JIT cannot find a way to optimize intelligently... Would
it be possible?

Thanks

ThunderMusic

"Aneesh P" <an******@gmail.comwrote in message
news:11**********************@z28g2000prd.googlegr oups.com...
On Jun 1, 10:33 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
>ThunderMusic,
This simply "does not compute". Are you actually installing this windows
service after it has been built in a debug build configuration? And you
are
comparing the performance against a different Windows Service
installation
that was done with a release build?

What I'd do (unless you want to get into some heavy-duty profiling) is
use
the Stopwatch class to take some start / finish timings around critical
operations that occur when your service runs, and write the results as
appended lines to a text file.

Examining this, if you have instrumented it properly, should give more
insight.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

"ThunderMusic" wrote:
Hi,
I have a windows service that only loads a CSV file and import it's
data
using SqlBulkCopy in a newly created Sql Server 2005 table using 25000
rows
batches.
If I build the service in debug mode and run it, I get descent
performances.
If I build it in release mode, I would expect it to at least stay as
fast
and maybe be faster, but I actually lose performance. I lose about 10%
performance.
How can this happen?
Here's what could be involved :
- SqlBulkCopy Class a IDataReader implementation as a source which
performance has been verified.
- <SqlDbTypes>.Parse(...)
- Array indexing
- Boxing and Unboxing of objects
- Generic classes (List, Dictionary, Hashtable) search by key
Thanks
ThunderMusic- Hide quoted text -

- Show quoted text -

I was using same kind of functionality, but in the reverse way,
loading data from SQL to CRM Server and then to MSMQ. Again from queue
to a CSV file. The performance is considerably better when I built the
windows service in release mode. I've found it out using the
aforementioned Stopwatch class. I'd venture to suggest the same.

Jun 1 '07 #7
If I build the service in debug mode and run it, I get descent performances.
If I build it in release mode, I would expect it to at least stay as fast
and maybe be faster, but I actually lose performance. I lose about 10%
performance.

How can this happen?
A stab in the dark ... Do you handle many exceptions? My experience is that
executing a 'try' gives no noticeable performance hit, but executing a
'catch' is very noticeable. So... maybe the non-catch part of your code runs
slower in debug (as intuition dictates), and maybe the catch parts of your
code run much slower in release (not sure why, perhaps there is more to
untangle). As I said, a stab in the dark.
Jun 2 '07 #8
AMercer <AM*****@discussions.microsoft.comwrote:
How can this happen?

A stab in the dark ... Do you handle many exceptions? My experience is that
executing a 'try' gives no noticeable performance hit, but executing a
'catch' is very noticeable. So... maybe the non-catch part of your code runs
slower in debug (as intuition dictates), and maybe the catch parts of your
code run much slower in release (not sure why, perhaps there is more to
untangle). As I said, a stab in the dark.
Catching an exception *in the debugger* takes a vast amount of time.
Catching an exception in a release build, not running in the debugger,
takes relatively little time. Unless you're throwing and catching
thousands and thousands of exceptions, there shouldn't be any
significant performance hit.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 2 '07 #9
No, I'm not throwing many exceptions. Actually, with the test we ran, none
were thrown. so it must be in the non-catch part... ;)

We still experience the problem independantly from being executed after a
reboot or after running a while. We tried to measure with StopWatch, but
nothing relevant came out of this because when run in a close loop,
StopWatch tend to add overhead and it almost doubled our processing time.
(in the file we are testing, we do a 4000000 iteration 'for' (rows, records)
with an inner 13 iteration 'for' (columns, fields). So if we try to measure
the total time doing parse and total time for writing in the array to send
to bulk copy and the total time of anything, the StopWatch make make it go
awry

Would you have any other ideas so we can find what is going on?

Thanks

ThunderMusic

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP********************@msnews.microsoft.com.. .
AMercer <AM*****@discussions.microsoft.comwrote:
How can this happen?

A stab in the dark ... Do you handle many exceptions? My experience is
that
executing a 'try' gives no noticeable performance hit, but executing a
'catch' is very noticeable. So... maybe the non-catch part of your code
runs
slower in debug (as intuition dictates), and maybe the catch parts of
your
code run much slower in release (not sure why, perhaps there is more to
untangle). As I said, a stab in the dark.

Catching an exception *in the debugger* takes a vast amount of time.
Catching an exception in a release build, not running in the debugger,
takes relatively little time. Unless you're throwing and catching
thousands and thousands of exceptions, there shouldn't be any
significant performance hit.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jun 4 '07 #10
"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:uN**************@TK2MSFTNGP04.phx.gbl...
No, I'm not throwing many exceptions. Actually, with the test we ran, none
were thrown. so it must be in the non-catch part... ;)

We still experience the problem independantly from being executed after a
reboot or after running a while. We tried to measure with StopWatch, but
nothing relevant came out of this because when run in a close loop,
StopWatch tend to add overhead and it almost doubled our processing time.
(in the file we are testing, we do a 4000000 iteration 'for' (rows,
records) with an inner 13 iteration 'for' (columns, fields). So if we try
to measure the total time doing parse and total time for writing in the
array to send to bulk copy and the total time of anything, the StopWatch
make make it go awry

Would you have any other ideas so we can find what is going on?

Thanks

ThunderMusic

I don't get is, when using StopWatch doubles the processing time, it looks
like you have your StopWatch calls at the wrong places, so I'm currious
where you inserted the StopWatch calls, my guess is for each iteration,
which is wrong when each iteration executes only a few statements. Mind to
post some code?
Also, did you compare the GC counters like Time Spent in GC and the number
of Collections done for each generational heap when running both release and
debug versions?

Willy.

Jun 4 '07 #11

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:66**********************************@microsof t.com...
"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:uN**************@TK2MSFTNGP04.phx.gbl...
>No, I'm not throwing many exceptions. Actually, with the test we ran,
none were thrown. so it must be in the non-catch part... ;)

We still experience the problem independantly from being executed after a
reboot or after running a while. We tried to measure with StopWatch, but
nothing relevant came out of this because when run in a close loop,
StopWatch tend to add overhead and it almost doubled our processing time.
(in the file we are testing, we do a 4000000 iteration 'for' (rows,
records) with an inner 13 iteration 'for' (columns, fields). So if we try
to measure the total time doing parse and total time for writing in the
array to send to bulk copy and the total time of anything, the StopWatch
make make it go awry

Would you have any other ideas so we can find what is going on?

Thanks

ThunderMusic


I don't get is, when using StopWatch doubles the processing time, it looks
like you have your StopWatch calls at the wrong places, so I'm currious
where you inserted the StopWatch calls, my guess is for each iteration,
which is wrong when each iteration executes only a few statements. Mind to
post some code?
Also, did you compare the GC counters like Time Spent in GC and the number
of Collections done for each generational heap when running both release
and debug versions?

Willy.
For the StopWatch, we tried to nail down a section of the code where the
processing is slower in release, but because of the structure of the code,
we cannot place it elsewhere than inside a loop because all the work is done
in a loop. So it's really hard to know exactly where we must look.

I cannot post code because it would be a violation of my contract because I
can't just simplify the code mainly because the problem could be anywhere in
it.

We didn't look for the GC counters... I'll look into that and come back with
the results.

Thanks

ThunderMusic
Jun 4 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jerry | last post by:
I have an SDI document that runs fine in Debug Mode but crashes in Release Mode. I have set up my project so I can debug in Release Mode. The project has a tab view Here is what is happening ...
1
by: spiff | last post by:
We are migrating from VC++ 6 to VC++ 2003. It is a plain, unmanaged application with both C and C++ source. When running the debug build, even outside the debugger, the memory allocation/deallocation...
3
by: Davef | last post by:
When you put you code in release, does all the code behind get compiled into a dll, -- Dave
1
by: Alex Levi | last post by:
I have 2 question. 1st: What is the difference between the Debug and Release mode when making an Exe file, when working at design time or in run time? 2nd: I was managed to make a setup...
6
by: Andrew Rowley | last post by:
I am having trouble getting debug and release builds to work properly with project references using C++ .NET and Visual Studio 2003. I created a test solution, with a basic Windows form C++...
5
by: Jonas Hallgren | last post by:
Hello, Is there any general tips on how to solve this problem: my Debug version runs fine but when I do a Release version I get error messages!? I'm hoping it is a simple option somewhere or...
11
by: ThunderMusic | last post by:
Hi, I have a windows service that only loads a CSV file and import it's data using SqlBulkCopy in a newly created Sql Server 2005 table using 25000 rows batches. If I build the service in debug...
4
by: John Sheppard | last post by:
Hello all, I have an application written in VB.Net that comsumes a webservice. We are having issues with speed. I have not ruled out a webservice problem, and this was my first guess. However...
3
by: =?Utf-8?B?bG10dGFn?= | last post by:
We have developed a number of different applications (ASP.NET web site, Windows services, DLLs, Windows forms, etc.) in C# 2.0. We have developed and unit tested all these applications/components...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.