The following slides show the history of a performance issue I faced in one of my applications and how I was able to solve it with tracing tools and some help of ChatGPT.
2. The following slides show the history
of a performance issue I faced in one
of my applications and how I was able
to solve it with tracing tools and
some help of ChatGPT.
About this topic
3. The function allows to easily export a
data set to an Excel sheet
The feature
A simple definition is enough …
… to transform data to Excel.
4. One day users reported
an error opening the
exported file
Investigation showed that the client ran
Into a timeout leading to an empty file.
I decided to use a stop-gap measure
for the time being …
5. Then I forgot the “quick fix”
for about 2 years…
… until it returned just recently
504 Gateway Timeout
The error 504 gateway timeout usually
occurs when one or more servers could
not complete the request within the
allotted time and does not receive a
timely response from gateway.
Azure Application Gateway
friendly reminded me to do
a proper root cause analysis
¯_(ツ)_/¯
6. Key considerations for
performance analysis
Interpretation
of Results
Selective
Profiling
Selectively profile specific
areas of your codebase that are
likely to be performance
bottlenecks
Iterative
After identifying potential
bottlenecks, make targeted
optimizations to improve
performance. Re-profile
afterwards and iterate.
Clear Goals
Understand what aspects of your
application's performance you want
to improve, e.g., response time,
throughput, or resource utilization
Look for methods with high
CPU usage, excessive memory
allocations, or long execution
times.
7. Iteration 1
- Focus on your code
- Don‘t care for waiting threads
- Find methods with long „own time“
→ AddRow uses 53 seconds, i.e. almost the
complete request
Selective Profiling
Start paused Begin data collection Run you workflow Wait for completion Get snapshot
Interpretation of Results
Running Expression.Compile
in a double nested loop…
→ Not a good idea 🤦
8. Fix 1
Moving all Compile calls to the initialization in AddField should do the trick …
…
9. Iteration 2
Interpretation of Results Looking at the code, I did not see where I might
have missed another Compile hence I asked ChatGPT:
Way better but 15 seconds is still too slow.
Why is it still compiling?
Polite as usual with great understanding of my code …
… and spot on!
10. Fix 2
Iteration 3
AddRow is gone for good 🥳
Some potential remains
→ StepsByTestingMethodAndAgent
Uses too much logging which can be easily fixed
Some things are just like they are
→ MeasureText is out of my control
and just takes time for 15000 Excel rows
→ Waiting for the remote DB
11. CREDITS: This presentation template was created by
Slidesgo, incluiding icons by Flaticon, and
infographics & images by Freepik.
THANKS!
I hope you enjoyed this small exercise on performance analysis!
Do you have any questions?
Please leave them in the comments section!
Markus Reinhardt | LinkedIn