SlideShare ist ein Scribd-Unternehmen logo
1 von 63
Troubleshooting .NET Core apps
on Linux
and very, very brief intro to Google Cloud
Pavel Klimiankou
The Plan
● A backstory
● Troubleshooting
○ Sampling
○ Tracing
○ Core dumps
● A little bit of Cloud
A backstory
● A backstory
● Troubleshooting
○ Sampling
○ Tracing
○ Core dumps
● A little bit of Cloud
We were locked on Windows for a long time
+ =
Very long time
+ =
Very, very long time
+ =
Until...
+ =
=
=
We want Linux!
But how do we debug on it?
Debugging
● A backstory
● Debugging
○ Sampling
○ Tracing
○ Core dumps
● A little bit of Cloud
PerfView and WinDBG on Linux?
Sampling
● A backstory
● Debugging
○ Sampling
○ Tracing
○ Core dumps
● A little bit of Cloud
Problem: CPU is 124%
Solution: sample and compare call stacks
Sample:
Solution: sample and compare call stacks
Sample: 0
Main
Solution: sample and compare call stacks
Sample: 0
Main
DoMath
Main
Generate
1
Solution: sample and compare call stacks
Sample: 0
Main
DoMath
Main
Generate
Main
DoMath
Generate
Multiply
1 2
Solution: sample and compare call stacks
Sample: 0
Main
DoMath
Main
Generate
Main
DoMath
Generate
Multiply
Main
DoMath
Generate
Multiply
1 2 3
Solution: sample and compare call stacks
Sample: 0
Main
DoMath
Main
Generate
Main
DoMath
Generate
Multiply
Main
DoMath
Generate
Multiply
1 2 3 SelfAll
100% 25%
75%
0%
75% 25%
50% 50%
Solution: sample and compare call stacks
Sample: 0
Main
DoMath
Main
Generate
Main
DoMath
Generate
Multiply
Main
DoMath
Generate
Multiply
1 2 3
100% 25%
75%
0%
75% 25%
50% 50%
SelfAll
That’s what “perf” does
1) apt-get install linux-tools-`uname -r`
2) sudo perf record -p %process_id% -g
3) sudo perf report -f
However, reported function names are missing
Just-In-Time to blame
C# IL
JIT
CLR
Native
Just-in-time to blame
C# IL
JIT
CLR
Native
This is what `perf` sees
This is what
we want
Solution: enable maps generation
export COMPlus_PerfMapEnabled=1
or
COMPlus_PerfMapEnabled=1 dotnet run
Voila!
Tracing
● A backstory
● Debugging
○ Sampling
○ Tracing
○ Core dumps
● A little bit of Cloud
Problem: want to see all thrown exceptions
Solution: use lttng and listen to runtime events
1) lttng create my-session
2) lttng enable-event --userspace --tracepoint
DotNETRuntime:Exception*
3) # start user application
4) lttng start
5) lttng stop
6) lttng destroy
Runtime events should be enabled first
export COMPlus_EnableEventLog=1
or
COMPlus_EnableEventLog=1 dotnet run
How to view results
babeltrace ~/lttng-traces/my-session*
Where do I find the list of all events?
View perfcollect source. To name a few:
● DotNETRuntime:GCStart
● DotNETRuntime:GCEnd
● DotNETRuntime:WorkerThreadCreate
● DotNETRuntime:WorkerThreadTerminate
● DotNETRuntime:ExceptionThrown
● DotNETRuntime:Contention
● DotNETRuntime:EventSource
● DotNETRuntime:AssemblyLoad
Core dumps
● A backstory
● Troubleshooting
○ Sampling
○ Tracing
○ Core dumps
● A little bit of Cloud
Problem: where did application memory go?
or Why did the process crashed?
or What’s happening right now?
Solution: get a core dump or attach to process
Core dump
Live process
or + lldb + libsosplugin
Target Debugger .NET Extension
Solution: get a core dump or attach to process
Core dump
Live process
or + lldb + libsosplugin
Target Debugger .NET Extension
How to get a core dump?
1) Manually: use gcore
2) Automatically: when process crashes
Core dump
Manually: using gcore
apt-get install gdb
sudo gcore %process id%
Core dump
Automatically: when process crashes
1) Set core dumps size limit: 0 by default
a) ulimit -c unlimited
b) /etc/security/limits.conf (permanently)
2) Set the path: useless by default
a) echo "core.%e.%p" > /proc/sys/kernel/core_pattern
b) /etc/sysctl.conf (permanently)
Core dump
How to get lldb?
1) apt-get install lldb-3.9 # for .NET Core SDK = 2.1
2) apt-get install lldb-3.6 # for .NET Core SDK < 2.1
3) Compile .NET Core SDK against any other lldb
lldb
How to get libsosplugin?
Easy. Comes along with SDK
libsosplugin
dotnet process ID 17400 took 249 MB of RAM
Take process dump, open debugger
1) sudo gcore 17400
2) lldb-3.9 `which dotnet` -c core.17400
3) (lldb) plugin load
/usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.0/lib
sosplugin.so
What’s memory statistics?
(lldb) dumpheap -stat
What are those strings?
(lldb) dumpheap -type System.String
Lots of 20056-byte strings. What’s inside?
(lldb) dumpobj 00007f55b4119ae0
Let’s follow _firstChar property, offset “c”
(lldb) memory read 00007f55b4119ae0+0xc
Nailed it!
lldb also can
1) Show threads
2) Stacks
3) Types and Assemblies
4) Set breakpoints
Links
● Profile .NET Core process
○ https://codeblog.dotsandbrackets.com/profiling-net-core-app-linux/
● Analyze process memory
○ https://codeblog.dotsandbrackets.com/net-core-memory-linux/
● Debug from command line
○ https://codeblog.dotsandbrackets.com/command-line-debugging-core-linux/
● Debugging session example
○ https://codeblog.dotsandbrackets.com/debug-adapter-process-has-terminated/
A cloud.
Google Cloud.
● A backstory
● Debugging
○ Sampling
○ Tracing
○ Core dumps
● A little bit of Cloud
What’s Google Cloud Platform is for
Minimum
Hosting your application in their data centers (IaaS)
Maximum
Building your application over their platform and services (PaaS)
What’s Google Cloud Platform is for
Application
Data
Compute Power
Storage
Network
Self hosting
OS/Middleware
Application
Data
Compute Power
Storage
Network
IaaS
OS/Middleware
Application
Data
Compute Power
Storage
Network
PaaS
OS/Middleware
Infrastructure as a Service: Google edition
Take a
1) Compute power (Compute Engine),
2) Storage (Persistent Disk) and
3) Network (just exists)
and tell everybody it’s a Cloud.
Platform as a Service: Compute options
Google Compute Engine
Google Container Engine
Google App Engine
Google Cloud Functions
More IaaS
More PaaS
Platform as a Service: Data/Storage options
Platform as a Service: Other goodies
How we use Google Cloud for CI/CD
Compute Engine
GitLab VM
Build Server 0 Build Server N
...
VM 0
Permanent
~1 month
~30 minutes VM 1
VM 4 VM 5
VM 8 VM 9
VM 0 VM 1
VM 4 VM 5
VM 8 VM 9
VM 1
VM 5
VM 9
Build artifacts
Test results
The End

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Testing Django APIs
Testing Django APIsTesting Django APIs
Testing Django APIs
 
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
Shenandoah GC: Java Without The Garbage Collection Hiccups (Christine Flood)
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 
Go Concurrency Basics
Go Concurrency Basics Go Concurrency Basics
Go Concurrency Basics
 
Austin Python Meetup 2017: What's New in Pythons 3.5 and 3.6?
Austin Python Meetup 2017: What's New in Pythons 3.5 and 3.6?Austin Python Meetup 2017: What's New in Pythons 3.5 and 3.6?
Austin Python Meetup 2017: What's New in Pythons 3.5 and 3.6?
 
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
 
PyCon Ukraine 2016: Maintaining a high load Python project for newcomers
PyCon Ukraine 2016: Maintaining a high load Python project for newcomersPyCon Ukraine 2016: Maintaining a high load Python project for newcomers
PyCon Ukraine 2016: Maintaining a high load Python project for newcomers
 
LCDS - State Presentation
LCDS - State PresentationLCDS - State Presentation
LCDS - State Presentation
 
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
 
Debugging TV Frame 0x0D
Debugging TV Frame 0x0DDebugging TV Frame 0x0D
Debugging TV Frame 0x0D
 
DevoxxPL: JRebel Under The Covers
DevoxxPL: JRebel Under The CoversDevoxxPL: JRebel Under The Covers
DevoxxPL: JRebel Under The Covers
 
Event loop
Event loopEvent loop
Event loop
 
Kernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtKernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring Naught
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Node Interactive Debugging Node.js In Production
Node Interactive Debugging Node.js In ProductionNode Interactive Debugging Node.js In Production
Node Interactive Debugging Node.js In Production
 
Streams for the Web
Streams for the WebStreams for the Web
Streams for the Web
 
What the &~#@&lt;!? (Pointers in Rust)
What the &~#@&lt;!? (Pointers in Rust)What the &~#@&lt;!? (Pointers in Rust)
What the &~#@&lt;!? (Pointers in Rust)
 
Groovy and Grails talk
Groovy and Grails talkGroovy and Grails talk
Groovy and Grails talk
 
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
 
Is your profiler speaking the same language as you? -- Docklands JUG
Is your profiler speaking the same language as you? -- Docklands JUGIs your profiler speaking the same language as you? -- Docklands JUG
Is your profiler speaking the same language as you? -- Docklands JUG
 

Ähnlich wie Troubleshooting .net core on linux

Kettunen, miaubiz fuzzing at scale and in style
Kettunen, miaubiz   fuzzing at scale and in styleKettunen, miaubiz   fuzzing at scale and in style
Kettunen, miaubiz fuzzing at scale and in style
DefconRussia
 
BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up
Craig Schumann
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharing
James Hsieh
 
May2010 hex-core-opt
May2010 hex-core-optMay2010 hex-core-opt
May2010 hex-core-opt
Jeff Larkin
 

Ähnlich wie Troubleshooting .net core on linux (20)

Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
 
Customize and Secure the Runtime and Dependencies of Your Procedural Language...
Customize and Secure the Runtime and Dependencies of Your Procedural Language...Customize and Secure the Runtime and Dependencies of Your Procedural Language...
Customize and Secure the Runtime and Dependencies of Your Procedural Language...
 
PythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummiesPythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummies
 
Kettunen, miaubiz fuzzing at scale and in style
Kettunen, miaubiz   fuzzing at scale and in styleKettunen, miaubiz   fuzzing at scale and in style
Kettunen, miaubiz fuzzing at scale and in style
 
Accelerated .NET Memory Dump Analysis training public slides
Accelerated .NET Memory Dump Analysis training public slidesAccelerated .NET Memory Dump Analysis training public slides
Accelerated .NET Memory Dump Analysis training public slides
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)
 
Tomcat from a cluster to the cloud on RP3
Tomcat from a cluster to the cloud on RP3Tomcat from a cluster to the cloud on RP3
Tomcat from a cluster to the cloud on RP3
 
Data race
Data raceData race
Data race
 
Multiprocessing with python
Multiprocessing with pythonMultiprocessing with python
Multiprocessing with python
 
BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up
 
Post mortem talk - Node Interactive EU
Post mortem talk - Node Interactive EUPost mortem talk - Node Interactive EU
Post mortem talk - Node Interactive EU
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharing
 
Perspectives on Docker
Perspectives on DockerPerspectives on Docker
Perspectives on Docker
 
Linux Kernel Platform Development: Challenges and Insights
 Linux Kernel Platform Development: Challenges and Insights Linux Kernel Platform Development: Challenges and Insights
Linux Kernel Platform Development: Challenges and Insights
 
Mender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and Golang
 
May2010 hex-core-opt
May2010 hex-core-optMay2010 hex-core-opt
May2010 hex-core-opt
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
 
A Brief Introduction of TiDB (Percona Live)
A Brief Introduction of TiDB (Percona Live)A Brief Introduction of TiDB (Percona Live)
A Brief Introduction of TiDB (Percona Live)
 
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
 

Mehr von Pavel Klimiankou

Mehr von Pavel Klimiankou (10)

Functional programming techniques in regular JavaScript
Functional programming techniques in regular JavaScriptFunctional programming techniques in regular JavaScript
Functional programming techniques in regular JavaScript
 
Приёмы функционального программирования в обычном JavaScript
Приёмы функционального программирования в обычном JavaScriptПриёмы функционального программирования в обычном JavaScript
Приёмы функционального программирования в обычном JavaScript
 
Browser APIs for data exchange: types and application
Browser APIs for data exchange: types and applicationBrowser APIs for data exchange: types and application
Browser APIs for data exchange: types and application
 
Браузерные API обмена данными: какие и зачем
Браузерные API обмена данными: какие и зачемБраузерные API обмена данными: какие и зачем
Браузерные API обмена данными: какие и зачем
 
Кратчайшая история JavaScript
Кратчайшая история JavaScriptКратчайшая история JavaScript
Кратчайшая история JavaScript
 
What is Docker
What is DockerWhat is Docker
What is Docker
 
Что такое Docker
Что такое DockerЧто такое Docker
Что такое Docker
 
Chrome Extensions
Chrome ExtensionsChrome Extensions
Chrome Extensions
 
Game physics in JavaScript
Game physics in JavaScriptGame physics in JavaScript
Game physics in JavaScript
 
Игровая физика в JavaScript
Игровая физика в JavaScriptИгровая физика в JavaScript
Игровая физика в JavaScript
 

Kürzlich hochgeladen

JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
Max Lee
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 

Kürzlich hochgeladen (20)

A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion Production
 
10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data Migration
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 

Troubleshooting .net core on linux

  • 1. Troubleshooting .NET Core apps on Linux and very, very brief intro to Google Cloud Pavel Klimiankou
  • 2. The Plan ● A backstory ● Troubleshooting ○ Sampling ○ Tracing ○ Core dumps ● A little bit of Cloud
  • 3. A backstory ● A backstory ● Troubleshooting ○ Sampling ○ Tracing ○ Core dumps ● A little bit of Cloud
  • 4. We were locked on Windows for a long time + =
  • 6. Very, very long time + =
  • 8. =
  • 9. =
  • 10. We want Linux! But how do we debug on it?
  • 11. Debugging ● A backstory ● Debugging ○ Sampling ○ Tracing ○ Core dumps ● A little bit of Cloud
  • 12. PerfView and WinDBG on Linux?
  • 13. Sampling ● A backstory ● Debugging ○ Sampling ○ Tracing ○ Core dumps ● A little bit of Cloud
  • 15. Solution: sample and compare call stacks Sample:
  • 16. Solution: sample and compare call stacks Sample: 0 Main
  • 17. Solution: sample and compare call stacks Sample: 0 Main DoMath Main Generate 1
  • 18. Solution: sample and compare call stacks Sample: 0 Main DoMath Main Generate Main DoMath Generate Multiply 1 2
  • 19. Solution: sample and compare call stacks Sample: 0 Main DoMath Main Generate Main DoMath Generate Multiply Main DoMath Generate Multiply 1 2 3
  • 20. Solution: sample and compare call stacks Sample: 0 Main DoMath Main Generate Main DoMath Generate Multiply Main DoMath Generate Multiply 1 2 3 SelfAll 100% 25% 75% 0% 75% 25% 50% 50%
  • 21. Solution: sample and compare call stacks Sample: 0 Main DoMath Main Generate Main DoMath Generate Multiply Main DoMath Generate Multiply 1 2 3 100% 25% 75% 0% 75% 25% 50% 50% SelfAll
  • 22. That’s what “perf” does 1) apt-get install linux-tools-`uname -r` 2) sudo perf record -p %process_id% -g 3) sudo perf report -f
  • 23. However, reported function names are missing
  • 24. Just-In-Time to blame C# IL JIT CLR Native
  • 25. Just-in-time to blame C# IL JIT CLR Native This is what `perf` sees This is what we want
  • 26. Solution: enable maps generation export COMPlus_PerfMapEnabled=1 or COMPlus_PerfMapEnabled=1 dotnet run
  • 28. Tracing ● A backstory ● Debugging ○ Sampling ○ Tracing ○ Core dumps ● A little bit of Cloud
  • 29. Problem: want to see all thrown exceptions
  • 30. Solution: use lttng and listen to runtime events 1) lttng create my-session 2) lttng enable-event --userspace --tracepoint DotNETRuntime:Exception* 3) # start user application 4) lttng start 5) lttng stop 6) lttng destroy
  • 31. Runtime events should be enabled first export COMPlus_EnableEventLog=1 or COMPlus_EnableEventLog=1 dotnet run
  • 32. How to view results babeltrace ~/lttng-traces/my-session*
  • 33. Where do I find the list of all events? View perfcollect source. To name a few: ● DotNETRuntime:GCStart ● DotNETRuntime:GCEnd ● DotNETRuntime:WorkerThreadCreate ● DotNETRuntime:WorkerThreadTerminate ● DotNETRuntime:ExceptionThrown ● DotNETRuntime:Contention ● DotNETRuntime:EventSource ● DotNETRuntime:AssemblyLoad
  • 34. Core dumps ● A backstory ● Troubleshooting ○ Sampling ○ Tracing ○ Core dumps ● A little bit of Cloud
  • 35. Problem: where did application memory go? or Why did the process crashed? or What’s happening right now?
  • 36. Solution: get a core dump or attach to process Core dump Live process or + lldb + libsosplugin Target Debugger .NET Extension
  • 37. Solution: get a core dump or attach to process Core dump Live process or + lldb + libsosplugin Target Debugger .NET Extension
  • 38. How to get a core dump? 1) Manually: use gcore 2) Automatically: when process crashes Core dump
  • 39. Manually: using gcore apt-get install gdb sudo gcore %process id% Core dump
  • 40. Automatically: when process crashes 1) Set core dumps size limit: 0 by default a) ulimit -c unlimited b) /etc/security/limits.conf (permanently) 2) Set the path: useless by default a) echo "core.%e.%p" > /proc/sys/kernel/core_pattern b) /etc/sysctl.conf (permanently) Core dump
  • 41. How to get lldb? 1) apt-get install lldb-3.9 # for .NET Core SDK = 2.1 2) apt-get install lldb-3.6 # for .NET Core SDK < 2.1 3) Compile .NET Core SDK against any other lldb lldb
  • 42. How to get libsosplugin? Easy. Comes along with SDK libsosplugin
  • 43. dotnet process ID 17400 took 249 MB of RAM
  • 44. Take process dump, open debugger 1) sudo gcore 17400 2) lldb-3.9 `which dotnet` -c core.17400 3) (lldb) plugin load /usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.0/lib sosplugin.so
  • 46. What are those strings? (lldb) dumpheap -type System.String
  • 47. Lots of 20056-byte strings. What’s inside? (lldb) dumpobj 00007f55b4119ae0
  • 48. Let’s follow _firstChar property, offset “c” (lldb) memory read 00007f55b4119ae0+0xc
  • 50. lldb also can 1) Show threads 2) Stacks 3) Types and Assemblies 4) Set breakpoints
  • 51. Links ● Profile .NET Core process ○ https://codeblog.dotsandbrackets.com/profiling-net-core-app-linux/ ● Analyze process memory ○ https://codeblog.dotsandbrackets.com/net-core-memory-linux/ ● Debug from command line ○ https://codeblog.dotsandbrackets.com/command-line-debugging-core-linux/ ● Debugging session example ○ https://codeblog.dotsandbrackets.com/debug-adapter-process-has-terminated/
  • 52.
  • 53. A cloud. Google Cloud. ● A backstory ● Debugging ○ Sampling ○ Tracing ○ Core dumps ● A little bit of Cloud
  • 54. What’s Google Cloud Platform is for Minimum Hosting your application in their data centers (IaaS) Maximum Building your application over their platform and services (PaaS)
  • 55. What’s Google Cloud Platform is for Application Data Compute Power Storage Network Self hosting OS/Middleware Application Data Compute Power Storage Network IaaS OS/Middleware Application Data Compute Power Storage Network PaaS OS/Middleware
  • 56. Infrastructure as a Service: Google edition Take a 1) Compute power (Compute Engine), 2) Storage (Persistent Disk) and 3) Network (just exists) and tell everybody it’s a Cloud.
  • 57. Platform as a Service: Compute options Google Compute Engine Google Container Engine Google App Engine Google Cloud Functions More IaaS More PaaS
  • 58. Platform as a Service: Data/Storage options
  • 59. Platform as a Service: Other goodies
  • 60. How we use Google Cloud for CI/CD Compute Engine GitLab VM Build Server 0 Build Server N ... VM 0 Permanent ~1 month ~30 minutes VM 1 VM 4 VM 5 VM 8 VM 9 VM 0 VM 1 VM 4 VM 5 VM 8 VM 9 VM 1 VM 5 VM 9 Build artifacts Test results
  • 61.
  • 62.