SlideShare a Scribd company logo
1 of 40
From ‘dotnet run’
to “Hello World”
@matthewwarren
mattwarren.org
From ‘dotnet run’
to “Hello World”
http://raygun.com/apm
I ❤ ‘.NET Internals’
Understand one level below
your usual abstraction
Neal Ford
Demo – “Hello World”
Outline
• Main Components
• Hosting the runtime
• CLR Initialisation
• Type Loader
• JIT Compilation
• Everything Else
Main Components
CoreCLR Repository
• 2.6 million of source code, under src
• 8.2 million lines of test code
• 24,485 Files (7,466 source & 17,019 test)
– 6,626 C# (956 source & 5,670 test)
– 2,074 C and C++
– 3,701 IL
– 93 Assembler, 43 Python & 6 Perl!!
Virtual Machine (VM)
• Type System, Generics
• Built-in Types
• Loading types/classes
• Threading
• Exception Handling and Stack Walking
• Event Tracing and Profiling
• P/Invoke
Hosting
Hosting API
1. Identify the managed entry point
2. Find and load CoreCLR.dll
3. Get an ICLRRuntimeHost2 Instance
4. Set start-up flags and start the runtime
5. Preparing AppDomain settings
6. Create the AppDomain
7. Run managed code
8. Clean up
https://docs.microsoft.com/en-us/dotnet/core/tutorials/netcore-hosting
Demo – Hosting API
Initialisation
Initialising the CLR
• Phase 1 - Set-up infrastructure for all components
• Phase 2 - Initialise the core, low-level components
• Phase 3 - Start-up the low-level components, i.e. error
handling, profiling API, debugging
• Phase 4 - Start the main components, i.e. GC & AppDomains
• Phase 5 - Final setup and send out a notification
http://mattwarren.org/2017/02/07/The-68-things-the-CLR-does-before-
executing-a-single-line-of-your-code/
Demo - PerfView
ImageCourtesyof
JuliaEvans
@b0rk–jvns.ca
https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals
Type Loader
http://mattwarren.org/2017/06/15/How-the-.NET-Rutime-loads-a-Type/
JIT Compilation
http://mattwarren.org/2017/12/15/How-does-.NET-JIT-a-
method-and-Tiered-Compilation/
Before JIT-ing
http://mattwarren.org/2017/12/15/How-does-.NET-JIT-a-
method-and-Tiered-Compilation/
Before JIT-ing
After JIT-ing
http://mattwarren.org/2017/12/15/How-does-.NET-JIT-a-
method-and-Tiered-Compilation/
Before JIT-ing
After JIT-ing with ‘Tiered Compilation’
http://mattwarren.org/2017/12/15/How-does-.NET-JIT-a-
method-and-Tiered-Compilation/
After JIT-ing with ‘Tiered Compilation’ - Optimised
Everything Else
Marshalling and P/Invoke
Resources
• http://mattwarren.org/tags/#Internals
– Resources for Learning about .NET Internals
– Exploring the Internals of the .NET Runtime
– Tools for Exploring .NET Internals
– Presentations and Talks covering '.NET Internals'
• Book of the Runtime (BotR)
– https://github.com/dotnet/coreclr/tree/master/Document
ation/botr
I ❤ ‘.NET Internals’
AMA

More Related Content

What's hot

PyOpenCLによるGPGPU入門
PyOpenCLによるGPGPU入門PyOpenCLによるGPGPU入門
PyOpenCLによるGPGPU入門
Yosuke Onoue
 
用十分鐘開始理解深度學習技術 (從 dnn.js 專案出發)
用十分鐘開始理解深度學習技術  (從 dnn.js 專案出發)用十分鐘開始理解深度學習技術  (從 dnn.js 專案出發)
用十分鐘開始理解深度學習技術 (從 dnn.js 專案出發)
鍾誠 陳鍾誠
 
ダブル配列の実装方法
ダブル配列の実装方法ダブル配列の実装方法
ダブル配列の実装方法
Higashiyama Masahiko
 

What's hot (20)

GNU ld的linker script簡介
GNU ld的linker script簡介GNU ld的linker script簡介
GNU ld的linker script簡介
 
PyOpenCLによるGPGPU入門
PyOpenCLによるGPGPU入門PyOpenCLによるGPGPU入門
PyOpenCLによるGPGPU入門
 
mTCP使ってみた
mTCP使ってみたmTCP使ってみた
mTCP使ってみた
 
06 基因 與 蛋白質
06 基因 與 蛋白質06 基因 與 蛋白質
06 基因 與 蛋白質
 
Hardware & Software Platforms for HPC, AI and ML
Hardware & Software Platforms for HPC, AI and MLHardware & Software Platforms for HPC, AI and ML
Hardware & Software Platforms for HPC, AI and ML
 
Async await in C++
Async await in C++Async await in C++
Async await in C++
 
Javaバイトコード入門
Javaバイトコード入門Javaバイトコード入門
Javaバイトコード入門
 
Go 製リアルタイムサーバーの Kubernetes での運用について
Go 製リアルタイムサーバーの  Kubernetes での運用についてGo 製リアルタイムサーバーの  Kubernetes での運用について
Go 製リアルタイムサーバーの Kubernetes での運用について
 
iOSにおけるパフォーマンス計測
iOSにおけるパフォーマンス計測iOSにおけるパフォーマンス計測
iOSにおけるパフォーマンス計測
 
[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階
 
用十分鐘開始理解深度學習技術 (從 dnn.js 專案出發)
用十分鐘開始理解深度學習技術  (從 dnn.js 專案出發)用十分鐘開始理解深度學習技術  (從 dnn.js 專案出發)
用十分鐘開始理解深度學習技術 (從 dnn.js 專案出發)
 
Kubernetes ControllerをScale-Outさせる方法 / Kubernetes Meetup Tokyo #55
Kubernetes ControllerをScale-Outさせる方法 / Kubernetes Meetup Tokyo #55Kubernetes ControllerをScale-Outさせる方法 / Kubernetes Meetup Tokyo #55
Kubernetes ControllerをScale-Outさせる方法 / Kubernetes Meetup Tokyo #55
 
淺談量子機器學習 - 當機器學習遇見量子計算
淺談量子機器學習 - 當機器學習遇見量子計算淺談量子機器學習 - 當機器學習遇見量子計算
淺談量子機器學習 - 當機器學習遇見量子計算
 
Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64
 
Ovs dpdk hwoffload way to full offload
Ovs dpdk hwoffload way to full offloadOvs dpdk hwoffload way to full offload
Ovs dpdk hwoffload way to full offload
 
4章 Linuxカーネル - 割り込み・例外 3
4章 Linuxカーネル - 割り込み・例外 34章 Linuxカーネル - 割り込み・例外 3
4章 Linuxカーネル - 割り込み・例外 3
 
ダブル配列の実装方法
ダブル配列の実装方法ダブル配列の実装方法
ダブル配列の実装方法
 
FPGA・リコンフィギャラブルシステム研究の最新動向
FPGA・リコンフィギャラブルシステム研究の最新動向FPGA・リコンフィギャラブルシステム研究の最新動向
FPGA・リコンフィギャラブルシステム研究の最新動向
 
KubeCon 2021 NA Recap - Scheduler拡張事例最前線 / Kubernetes Meetup Tokyo #47 / #k8sjp
KubeCon 2021 NA Recap - Scheduler拡張事例最前線 / Kubernetes Meetup Tokyo #47 / #k8sjpKubeCon 2021 NA Recap - Scheduler拡張事例最前線 / Kubernetes Meetup Tokyo #47 / #k8sjp
KubeCon 2021 NA Recap - Scheduler拡張事例最前線 / Kubernetes Meetup Tokyo #47 / #k8sjp
 
GPD-WINや中華ノートPCなどATOM機器に 各種Linuxディストリを入れて遊ぼう Install Linux Distributions on G...
GPD-WINや中華ノートPCなどATOM機器に 各種Linuxディストリを入れて遊ぼう Install Linux Distributions on G...GPD-WINや中華ノートPCなどATOM機器に 各種Linuxディストリを入れて遊ぼう Install Linux Distributions on G...
GPD-WINや中華ノートPCなどATOM機器に 各種Linuxディストリを入れて遊ぼう Install Linux Distributions on G...
 

Similar to From 'dotnet run' to 'hello world'

MattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxMattsonTutorialSC14.pptx
MattsonTutorialSC14.pptx
gopikahari7
 
Windows内核技术介绍
Windows内核技术介绍Windows内核技术介绍
Windows内核技术介绍
jeffz
 

Similar to From 'dotnet run' to 'hello world' (20)

From 'dotnet run' to 'hello world'
From 'dotnet run' to 'hello world'From 'dotnet run' to 'hello world'
From 'dotnet run' to 'hello world'
 
Raffaele Rialdi
Raffaele RialdiRaffaele Rialdi
Raffaele Rialdi
 
Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++
 
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...
 
Mastering Terraform and the Provider for OCI
Mastering Terraform and the Provider for OCIMastering Terraform and the Provider for OCI
Mastering Terraform and the Provider for OCI
 
MattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdf
 
Practical Windows Kernel Exploitation
Practical Windows Kernel ExploitationPractical Windows Kernel Exploitation
Practical Windows Kernel Exploitation
 
Indic threads pune12-accelerating computation in html 5
Indic threads pune12-accelerating computation in html 5Indic threads pune12-accelerating computation in html 5
Indic threads pune12-accelerating computation in html 5
 
Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native code
 
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't driveDEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
 
MattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxMattsonTutorialSC14.pptx
MattsonTutorialSC14.pptx
 
Windows内核技术介绍
Windows内核技术介绍Windows内核技术介绍
Windows内核技术介绍
 
C++ in kernel mode
C++ in kernel modeC++ in kernel mode
C++ in kernel mode
 
stackconf 2020 | Replace your Docker based Containers with Cri-o Kata Contain...
stackconf 2020 | Replace your Docker based Containers with Cri-o Kata Contain...stackconf 2020 | Replace your Docker based Containers with Cri-o Kata Contain...
stackconf 2020 | Replace your Docker based Containers with Cri-o Kata Contain...
 
PANDEMONIUM: Automated Identification of Cryptographic Algorithms using Dynam...
PANDEMONIUM: Automated Identification of Cryptographic Algorithms using Dynam...PANDEMONIUM: Automated Identification of Cryptographic Algorithms using Dynam...
PANDEMONIUM: Automated Identification of Cryptographic Algorithms using Dynam...
 
Inside CoreCLR
Inside CoreCLRInside CoreCLR
Inside CoreCLR
 
OrigoDB - take the red pill
OrigoDB - take the red pillOrigoDB - take the red pill
OrigoDB - take the red pill
 
Defending Your "Gold"
Defending Your "Gold"Defending Your "Gold"
Defending Your "Gold"
 
06.1 .Net memory management
06.1 .Net memory management06.1 .Net memory management
06.1 .Net memory management
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
 

More from Matt Warren

More from Matt Warren (8)

Microsoft & open source a 'brave new world' - CORESTART 2.0
Microsoft & open source a 'brave new world' - CORESTART 2.0Microsoft & open source a 'brave new world' - CORESTART 2.0
Microsoft & open source a 'brave new world' - CORESTART 2.0
 
Microsoft & Open Source - a 'brave new world' - ProgSCon 2017
Microsoft & Open Source - a 'brave new world' - ProgSCon 2017Microsoft & Open Source - a 'brave new world' - ProgSCon 2017
Microsoft & Open Source - a 'brave new world' - ProgSCon 2017
 
Where the wild things are - Benchmarking and Micro-Optimisations
Where the wild things are - Benchmarking and Micro-OptimisationsWhere the wild things are - Benchmarking and Micro-Optimisations
Where the wild things are - Benchmarking and Micro-Optimisations
 
Performance is a Feature! at DDD 11
Performance is a Feature! at DDD 11Performance is a Feature! at DDD 11
Performance is a Feature! at DDD 11
 
Performance and how to measure it - ProgSCon London 2016
Performance and how to measure it - ProgSCon London 2016Performance and how to measure it - ProgSCon London 2016
Performance and how to measure it - ProgSCon London 2016
 
Performance is a feature! - London .NET User Group
Performance is a feature! - London .NET User GroupPerformance is a feature! - London .NET User Group
Performance is a feature! - London .NET User Group
 
Performance is a feature! - Developer South Coast - part 2
Performance is a feature!  - Developer South Coast - part 2Performance is a feature!  - Developer South Coast - part 2
Performance is a feature! - Developer South Coast - part 2
 
Performance is a feature! - Developer South Coast - part 1
Performance is a feature! - Developer South Coast - part 1Performance is a feature! - Developer South Coast - part 1
Performance is a feature! - Developer South Coast - part 1
 

Recently uploaded

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 

From 'dotnet run' to 'hello world'

Editor's Notes

  1. We’re Engineers, we love knowing what’s going on ‘under the hood’ Helps with Perf (Ben Adams, Kestrel, TechEmpower, deep JIT knowledge) As a community we should understand our ecosystem
  2. mscorlib is now System.Private.CoreLib
  3. mscorlib is now System.Private.CoreLib
  4. mscorlib is now System.Private.CoreLib
  5. mscorlib is now System.Private.CoreLib
  6. mscorlib is now System.Private.CoreLib
  7. mscorlib is now System.Private.CoreLib
  8. mscorlib is now System.Private.CoreLib
  9. mscorlib is now System.Private.CoreLib
  10. Phase 1 – Config, ThreadManager, ETW Events, Diagnostics & Perf logs Phase 2 – Assembly Binding (aka “Fusion”), Perf Counters, Stub Manager, Debugger Manager Phase 3 – Also initial runtime thread is started Phase 4 – Code Access Security (CAS), Stack Probes, Phase 5 - Set-up all the shared static variables
  11. Partially filled in ‘data structures’ More data is added at each step A class can only progress through the steps if it’s dependencies also progress