Omar
Omar
CC#
Created by Omar on 12/28/2024 in #help
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
CC#
Created by Omar on 9/3/2023 in #help
❔ Why is C# so slow on Linux? How can I speed it up?
Just "Hello World" take almost three seconds to execute.
$ time dotnet run --no-build --property:Configuration=Release
Hello, World!

real 0m2.798s
user 0m3.404s
sys 0m0.576s
$ time dotnet run --no-build --property:Configuration=Release
Hello, World!

real 0m2.798s
user 0m3.404s
sys 0m0.576s
What can I do to speed it up?
100 replies
CC#
Created by Omar on 7/28/2023 in #help
❔ Package to decode FLAC files?
Can anyone recommend a C# package to decode FLAC files? I want to be able to read the FLAC file from disk, and have the decompressed waveform data in memory to process directly.
27 replies
CC#
Created by Omar on 2/23/2023 in #help
❔ 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
CC#
Created by Omar on 10/15/2022 in #help
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