SlideShare a Scribd company logo
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/
Troubleshooting .net core on linux
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
Troubleshooting .net core on linux
Troubleshooting .net core on linux
The End

More Related Content

What's hot (20)

Testing Django APIs
Testing Django APIsTesting Django APIs
Testing Django APIs
tyomo4ka
 
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)
Red Hat Developers
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
Pradeep Kumar TS
 
Go Concurrency Basics
Go Concurrency Basics Go Concurrency Basics
Go Concurrency Basics
ElifTech
 
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?
Viach Kakovskyi
 
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...
Tsundere Chen
 
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
Viach Kakovskyi
 
LCDS - State Presentation
LCDS - State PresentationLCDS - State Presentation
LCDS - State Presentation
Ruochun Tzeng
 
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
Ceph Community
 
Debugging TV Frame 0x0D
Debugging TV Frame 0x0DDebugging TV Frame 0x0D
Debugging TV Frame 0x0D
Dmitry Vostokov
 
DevoxxPL: JRebel Under The Covers
DevoxxPL: JRebel Under The CoversDevoxxPL: JRebel Under The Covers
DevoxxPL: JRebel Under The Covers
Simon Maple
 
Event loop
Event loopEvent loop
Event loop
codepitbull
 
Kernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtKernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring Naught
David Evans
 
Synchronization
SynchronizationSynchronization
Synchronization
David Evans
 
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
Yunong Xiao
 
Streams for the Web
Streams for the WebStreams for the Web
Streams for the Web
Domenic Denicola
 
What the &~#@&lt;!? (Pointers in Rust)
What the &~#@&lt;!? (Pointers in Rust)What the &~#@&lt;!? (Pointers in Rust)
What the &~#@&lt;!? (Pointers in Rust)
David Evans
 
Groovy and Grails talk
Groovy and Grails talkGroovy and Grails talk
Groovy and Grails talk
desistartups
 
[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
Zhen Wei
 
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
Simon Maple
 
Testing Django APIs
Testing Django APIsTesting Django APIs
Testing Django APIs
tyomo4ka
 
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)
Red Hat Developers
 
Go Concurrency Basics
Go Concurrency Basics Go Concurrency Basics
Go Concurrency Basics
ElifTech
 
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?
Viach Kakovskyi
 
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...
Tsundere Chen
 
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
Viach Kakovskyi
 
LCDS - State Presentation
LCDS - State PresentationLCDS - State Presentation
LCDS - State Presentation
Ruochun Tzeng
 
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
Ceph Community
 
DevoxxPL: JRebel Under The Covers
DevoxxPL: JRebel Under The CoversDevoxxPL: JRebel Under The Covers
DevoxxPL: JRebel Under The Covers
Simon Maple
 
Kernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtKernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring Naught
David Evans
 
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
Yunong Xiao
 
What the &~#@&lt;!? (Pointers in Rust)
What the &~#@&lt;!? (Pointers in Rust)What the &~#@&lt;!? (Pointers in Rust)
What the &~#@&lt;!? (Pointers in Rust)
David Evans
 
Groovy and Grails talk
Groovy and Grails talkGroovy and Grails talk
Groovy and Grails talk
desistartups
 
[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
Zhen Wei
 
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
Simon Maple
 

Similar to Troubleshooting .net core on linux (20)

.NET Debugging Workshop
.NET Debugging Workshop.NET Debugging Workshop
.NET Debugging Workshop
Sasha Goldshtein
 
Debugging NET Applications With WinDBG
Debugging  NET Applications With WinDBGDebugging  NET Applications With WinDBG
Debugging NET Applications With WinDBG
Cory Foy
 
Unpacking .NET Core | EastBanc Technologies
Unpacking .NET Core | EastBanc TechnologiesUnpacking .NET Core | EastBanc Technologies
Unpacking .NET Core | EastBanc Technologies
EastBanc Tachnologies
 
.Net debugging 2017
.Net debugging   2017.Net debugging   2017
.Net debugging 2017
Tess Ferrandez
 
Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)
Mirco Vanini
 
C# Production Debugging Made Easy
 C# Production Debugging Made Easy C# Production Debugging Made Easy
C# Production Debugging Made Easy
Alon Fliess
 
Production Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyProduction Debugging at Code Camp Philly
Production Debugging at Code Camp Philly
Brian Lyttle
 
Debugging node in prod
Debugging node in prodDebugging node in prod
Debugging node in prod
Yunong Xiao
 
Key Steps in Developing .NET Core Applications
Key Steps in Developing .NET Core ApplicationsKey Steps in Developing .NET Core Applications
Key Steps in Developing .NET Core Applications
Damir Dobric
 
Tamir Dresher - Demystifying the Core of .NET Core
Tamir Dresher  - Demystifying the Core of .NET CoreTamir Dresher  - Demystifying the Core of .NET Core
Tamir Dresher - Demystifying the Core of .NET Core
Tamir Dresher
 
Raffaele Rialdi
Raffaele RialdiRaffaele Rialdi
Raffaele Rialdi
CodeFest
 
Troubleshooting .NET Applications on Cloud Foundry
Troubleshooting .NET Applications on Cloud FoundryTroubleshooting .NET Applications on Cloud Foundry
Troubleshooting .NET Applications on Cloud Foundry
Altoros
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NET
Maarten Balliauw
 
.NET Core Blimey! Windows Platform User Group, Manchester
.NET Core Blimey! Windows Platform User Group, Manchester.NET Core Blimey! Windows Platform User Group, Manchester
.NET Core Blimey! Windows Platform User Group, Manchester
citizenmatt
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques
Bala Subra
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging Techniques
Bala Subra
 
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management....NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
NETFest
 
Production debugging web applications
Production debugging web applicationsProduction debugging web applications
Production debugging web applications
Ido Flatow
 
.NET Core Blimey! (Shropshire Devs Mar 2016)
.NET Core Blimey! (Shropshire Devs Mar 2016).NET Core Blimey! (Shropshire Devs Mar 2016)
.NET Core Blimey! (Shropshire Devs Mar 2016)
citizenmatt
 
.NET Core Blimey! (dotnetsheff Jan 2016)
.NET Core Blimey! (dotnetsheff Jan 2016).NET Core Blimey! (dotnetsheff Jan 2016)
.NET Core Blimey! (dotnetsheff Jan 2016)
citizenmatt
 
Debugging NET Applications With WinDBG
Debugging  NET Applications With WinDBGDebugging  NET Applications With WinDBG
Debugging NET Applications With WinDBG
Cory Foy
 
Unpacking .NET Core | EastBanc Technologies
Unpacking .NET Core | EastBanc TechnologiesUnpacking .NET Core | EastBanc Technologies
Unpacking .NET Core | EastBanc Technologies
EastBanc Tachnologies
 
Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)
Mirco Vanini
 
C# Production Debugging Made Easy
 C# Production Debugging Made Easy C# Production Debugging Made Easy
C# Production Debugging Made Easy
Alon Fliess
 
Production Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyProduction Debugging at Code Camp Philly
Production Debugging at Code Camp Philly
Brian Lyttle
 
Debugging node in prod
Debugging node in prodDebugging node in prod
Debugging node in prod
Yunong Xiao
 
Key Steps in Developing .NET Core Applications
Key Steps in Developing .NET Core ApplicationsKey Steps in Developing .NET Core Applications
Key Steps in Developing .NET Core Applications
Damir Dobric
 
Tamir Dresher - Demystifying the Core of .NET Core
Tamir Dresher  - Demystifying the Core of .NET CoreTamir Dresher  - Demystifying the Core of .NET Core
Tamir Dresher - Demystifying the Core of .NET Core
Tamir Dresher
 
Raffaele Rialdi
Raffaele RialdiRaffaele Rialdi
Raffaele Rialdi
CodeFest
 
Troubleshooting .NET Applications on Cloud Foundry
Troubleshooting .NET Applications on Cloud FoundryTroubleshooting .NET Applications on Cloud Foundry
Troubleshooting .NET Applications on Cloud Foundry
Altoros
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NET
Maarten Balliauw
 
.NET Core Blimey! Windows Platform User Group, Manchester
.NET Core Blimey! Windows Platform User Group, Manchester.NET Core Blimey! Windows Platform User Group, Manchester
.NET Core Blimey! Windows Platform User Group, Manchester
citizenmatt
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques
Bala Subra
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging Techniques
Bala Subra
 
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management....NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
NETFest
 
Production debugging web applications
Production debugging web applicationsProduction debugging web applications
Production debugging web applications
Ido Flatow
 
.NET Core Blimey! (Shropshire Devs Mar 2016)
.NET Core Blimey! (Shropshire Devs Mar 2016).NET Core Blimey! (Shropshire Devs Mar 2016)
.NET Core Blimey! (Shropshire Devs Mar 2016)
citizenmatt
 
.NET Core Blimey! (dotnetsheff Jan 2016)
.NET Core Blimey! (dotnetsheff Jan 2016).NET Core Blimey! (dotnetsheff Jan 2016)
.NET Core Blimey! (dotnetsheff Jan 2016)
citizenmatt
 
Ad

More from 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
Pavel Klimiankou
 
Приёмы функционального программирования в обычном JavaScript
Приёмы функционального программирования в обычном JavaScriptПриёмы функционального программирования в обычном JavaScript
Приёмы функционального программирования в обычном JavaScript
Pavel Klimiankou
 
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
Pavel Klimiankou
 
Браузерные API обмена данными: какие и зачем
Браузерные API обмена данными: какие и зачемБраузерные API обмена данными: какие и зачем
Браузерные API обмена данными: какие и зачем
Pavel Klimiankou
 
Кратчайшая история JavaScript
Кратчайшая история JavaScriptКратчайшая история JavaScript
Кратчайшая история JavaScript
Pavel Klimiankou
 
What is Docker
What is DockerWhat is Docker
What is Docker
Pavel Klimiankou
 
Что такое Docker
Что такое DockerЧто такое Docker
Что такое Docker
Pavel Klimiankou
 
Chrome Extensions
Chrome ExtensionsChrome Extensions
Chrome Extensions
Pavel Klimiankou
 
Game physics in JavaScript
Game physics in JavaScriptGame physics in JavaScript
Game physics in JavaScript
Pavel Klimiankou
 
Игровая физика в JavaScript
Игровая физика в JavaScriptИгровая физика в JavaScript
Игровая физика в JavaScript
Pavel Klimiankou
 
Functional programming techniques in regular JavaScript
Functional programming techniques in regular JavaScriptFunctional programming techniques in regular JavaScript
Functional programming techniques in regular JavaScript
Pavel Klimiankou
 
Приёмы функционального программирования в обычном JavaScript
Приёмы функционального программирования в обычном JavaScriptПриёмы функционального программирования в обычном JavaScript
Приёмы функционального программирования в обычном JavaScript
Pavel Klimiankou
 
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
Pavel Klimiankou
 
Браузерные API обмена данными: какие и зачем
Браузерные API обмена данными: какие и зачемБраузерные API обмена данными: какие и зачем
Браузерные API обмена данными: какие и зачем
Pavel Klimiankou
 
Кратчайшая история JavaScript
Кратчайшая история JavaScriptКратчайшая история JavaScript
Кратчайшая история JavaScript
Pavel Klimiankou
 
Game physics in JavaScript
Game physics in JavaScriptGame physics in JavaScript
Game physics in JavaScript
Pavel Klimiankou
 
Игровая физика в JavaScript
Игровая физика в JavaScriptИгровая физика в JavaScript
Игровая физика в JavaScript
Pavel Klimiankou
 
Ad

Recently uploaded (20)

Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Prachi Desai
 
Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!
PhilMeredith3
 
Feeling Lost in the Blue? Exploring a New Path: AI Mental Health Counselling ...
Feeling Lost in the Blue? Exploring a New Path: AI Mental Health Counselling ...Feeling Lost in the Blue? Exploring a New Path: AI Mental Health Counselling ...
Feeling Lost in the Blue? Exploring a New Path: AI Mental Health Counselling ...
officeiqai
 
Software Risk and Quality management.pptx
Software Risk and Quality management.pptxSoftware Risk and Quality management.pptx
Software Risk and Quality management.pptx
HassanBangash9
 
War Story: Removing Offensive Language from Percona Toolkit
War Story: Removing Offensive Language from Percona ToolkitWar Story: Removing Offensive Language from Percona Toolkit
War Story: Removing Offensive Language from Percona Toolkit
Sveta Smirnova
 
Custom Software Development: Types, Applications and Benefits.pdf
Custom Software Development: Types, Applications and Benefits.pdfCustom Software Development: Types, Applications and Benefits.pdf
Custom Software Development: Types, Applications and Benefits.pdf
Digital Aptech
 
Boost Student Engagement with Smart Attendance Software for Schools
Boost Student Engagement with Smart Attendance Software for SchoolsBoost Student Engagement with Smart Attendance Software for Schools
Boost Student Engagement with Smart Attendance Software for Schools
Visitu
 
Techdebt handling with cleancode focus and as risk taker
Techdebt handling with cleancode focus and as risk takerTechdebt handling with cleancode focus and as risk taker
Techdebt handling with cleancode focus and as risk taker
RajaNagendraKumar
 
Issues in AI Presentation and machine learning.pptx
Issues in AI Presentation and machine learning.pptxIssues in AI Presentation and machine learning.pptx
Issues in AI Presentation and machine learning.pptx
Jalalkhan657136
 
The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...
Prachi Desai
 
ICDL FULL STANDARD 2025 Luisetto mauro - Academia domani- 55 HOURS LONG pdf
ICDL FULL STANDARD  2025 Luisetto mauro - Academia domani- 55 HOURS LONG pdfICDL FULL STANDARD  2025 Luisetto mauro - Academia domani- 55 HOURS LONG pdf
ICDL FULL STANDARD 2025 Luisetto mauro - Academia domani- 55 HOURS LONG pdf
M. Luisetto Pharm.D.Spec. Pharmacology
 
Internship in South western railways on software
Internship in South western railways on softwareInternship in South western railways on software
Internship in South western railways on software
abhim5889
 
Facility Management Solution - TeroTAM CMMS Software
Facility Management Solution - TeroTAM CMMS SoftwareFacility Management Solution - TeroTAM CMMS Software
Facility Management Solution - TeroTAM CMMS Software
TeroTAM
 
Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...
Rishab Acharya
 
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
UberEats clone app Development TechBuilder
UberEats clone app Development  TechBuilderUberEats clone app Development  TechBuilder
UberEats clone app Development TechBuilder
TechBuilder
 
AI-ASSISTED METAMORPHIC TESTING FOR DOMAIN-SPECIFIC MODELLING AND SIMULATION
AI-ASSISTED METAMORPHIC TESTING FOR DOMAIN-SPECIFIC MODELLING AND SIMULATIONAI-ASSISTED METAMORPHIC TESTING FOR DOMAIN-SPECIFIC MODELLING AND SIMULATION
AI-ASSISTED METAMORPHIC TESTING FOR DOMAIN-SPECIFIC MODELLING AND SIMULATION
miso_uam
 
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
Nacho Cougil
 
Content Mate Web App Triples Content Managers‘ Productivity
Content Mate Web App Triples Content Managers‘ ProductivityContent Mate Web App Triples Content Managers‘ Productivity
Content Mate Web App Triples Content Managers‘ Productivity
Alex Vladimirovich
 
Shortcomings of EHS Software – And How to Overcome Them
Shortcomings of EHS Software – And How to Overcome ThemShortcomings of EHS Software – And How to Overcome Them
Shortcomings of EHS Software – And How to Overcome Them
TECH EHS Solution
 
Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Prachi Desai
 
Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!
PhilMeredith3
 
Feeling Lost in the Blue? Exploring a New Path: AI Mental Health Counselling ...
Feeling Lost in the Blue? Exploring a New Path: AI Mental Health Counselling ...Feeling Lost in the Blue? Exploring a New Path: AI Mental Health Counselling ...
Feeling Lost in the Blue? Exploring a New Path: AI Mental Health Counselling ...
officeiqai
 
Software Risk and Quality management.pptx
Software Risk and Quality management.pptxSoftware Risk and Quality management.pptx
Software Risk and Quality management.pptx
HassanBangash9
 
War Story: Removing Offensive Language from Percona Toolkit
War Story: Removing Offensive Language from Percona ToolkitWar Story: Removing Offensive Language from Percona Toolkit
War Story: Removing Offensive Language from Percona Toolkit
Sveta Smirnova
 
Custom Software Development: Types, Applications and Benefits.pdf
Custom Software Development: Types, Applications and Benefits.pdfCustom Software Development: Types, Applications and Benefits.pdf
Custom Software Development: Types, Applications and Benefits.pdf
Digital Aptech
 
Boost Student Engagement with Smart Attendance Software for Schools
Boost Student Engagement with Smart Attendance Software for SchoolsBoost Student Engagement with Smart Attendance Software for Schools
Boost Student Engagement with Smart Attendance Software for Schools
Visitu
 
Techdebt handling with cleancode focus and as risk taker
Techdebt handling with cleancode focus and as risk takerTechdebt handling with cleancode focus and as risk taker
Techdebt handling with cleancode focus and as risk taker
RajaNagendraKumar
 
Issues in AI Presentation and machine learning.pptx
Issues in AI Presentation and machine learning.pptxIssues in AI Presentation and machine learning.pptx
Issues in AI Presentation and machine learning.pptx
Jalalkhan657136
 
The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...
Prachi Desai
 
ICDL FULL STANDARD 2025 Luisetto mauro - Academia domani- 55 HOURS LONG pdf
ICDL FULL STANDARD  2025 Luisetto mauro - Academia domani- 55 HOURS LONG pdfICDL FULL STANDARD  2025 Luisetto mauro - Academia domani- 55 HOURS LONG pdf
ICDL FULL STANDARD 2025 Luisetto mauro - Academia domani- 55 HOURS LONG pdf
M. Luisetto Pharm.D.Spec. Pharmacology
 
Internship in South western railways on software
Internship in South western railways on softwareInternship in South western railways on software
Internship in South western railways on software
abhim5889
 
Facility Management Solution - TeroTAM CMMS Software
Facility Management Solution - TeroTAM CMMS SoftwareFacility Management Solution - TeroTAM CMMS Software
Facility Management Solution - TeroTAM CMMS Software
TeroTAM
 
Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...
Rishab Acharya
 
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
UberEats clone app Development TechBuilder
UberEats clone app Development  TechBuilderUberEats clone app Development  TechBuilder
UberEats clone app Development TechBuilder
TechBuilder
 
AI-ASSISTED METAMORPHIC TESTING FOR DOMAIN-SPECIFIC MODELLING AND SIMULATION
AI-ASSISTED METAMORPHIC TESTING FOR DOMAIN-SPECIFIC MODELLING AND SIMULATIONAI-ASSISTED METAMORPHIC TESTING FOR DOMAIN-SPECIFIC MODELLING AND SIMULATION
AI-ASSISTED METAMORPHIC TESTING FOR DOMAIN-SPECIFIC MODELLING AND SIMULATION
miso_uam
 
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
Nacho Cougil
 
Content Mate Web App Triples Content Managers‘ Productivity
Content Mate Web App Triples Content Managers‘ ProductivityContent Mate Web App Triples Content Managers‘ Productivity
Content Mate Web App Triples Content Managers‘ Productivity
Alex Vladimirovich
 
Shortcomings of EHS Software – And How to Overcome Them
Shortcomings of EHS Software – And How to Overcome ThemShortcomings of EHS Software – And How to Overcome Them
Shortcomings of EHS Software – And How to Overcome Them
TECH EHS Solution
 

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/
  • 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