Omar
Surprising performance problem under debugger
Using NET 8.0 and Visual Studio 2022 Enterprise.
I've written an application that reads large XML files, does some processing on them, and then inserts records into SQL Server.
It works great, except it's slow. It executes 400 to 500 batches per second when I run it. That stinks!
To try to figure out what was wrong, I ran it under the profile (Debug > Performance Profiler). I turned on EWT and sampling, and I was off to the races.
I was very surprised that it ran at its expected speed! It can clear more than 35,000 batches per second, peaking at over 45,000/sec sometimes. What the heck? I didn't notice anything in the profile: SQL is the slowest, and I expect that. My parsing and processing does some work, but it's still faster than reading the input file.
So I tried running the app directly from the command line, without the debugger. Turns out it runs at very fast there, too. What gives? I'd expect some performance impact from the debugger, but not much -- and certainly not 100 times slower. And so I spent a lot of time assuming I had done something wrong: connection pool not working, locking where I thought I wasn't, getting single-threaded when I should've have been concurrent, ... ? Turns out it was the debugger the whole time.
What gives? Is this just a fact, or is there some setting I can diddle that will make app performance under the debugger more realistic? What is it that the debugger is doing to the process that's making it so awful?
13 replies
❔ How do I Open Source Software correctly?
I'm worried that I don't know how to OSS correctly.
How do I choose a library? I want to write C# code that controls and monitors Docker containers. How do I find a good, supported library that does it?
I searched around and found this one: https://www.nuget.org/packages/Docker.DotNet/ Where do I find documentation for this library? There's a README, but it's incomplete, just some examples; covers about 10% of the library, I figure. How do I learn more?
33 replies
any benefit to async?
What's the benefit of async code? I see lots of examples that
await
on all the async calls. A prominent example at hand is the XmlReader
example here: https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmlreader?redirectedfrom=MSDN&view=net-6.0
Since every call to ReadAsyc() is going to block on await, then what's the point of using async reads?114 replies