Microsoft Academic Program.NET Performanzanalyse und Optimierung Matej Ciesko Student Technology...
-
Upload
natalie-hunt -
Category
Documents
-
view
218 -
download
1
Transcript of Microsoft Academic Program.NET Performanzanalyse und Optimierung Matej Ciesko Student Technology...
Microsoft Academic Program
.NET Performanzanalyse und Optimierung
Matej Ciesko
Student Technology Conference 2005
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
2/23
Microsoft Academic Program
Student Technology Conference 2005
.NET Performanzanalyse und Optimierung
• Matej Ciesko• SSP – Microsoft Academic Program• Microsoft Deutschland GmbH• [email protected]
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
3/23
Microsoft Academic Program
Student Technology Conference 2005Moore’s Law
Anzahl der Transistoren verdoppelt sich alle 18 Monate
Intel Corp.
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
4/23
Microsoft Academic Program
Student Technology Conference 2005Agenda
Microsoft .NET Framework
Common Language Runtime
Base Classes
Web Services User Interface
Data and XML
ADO.NET XML ... ...
Operating SystemOperating System
HardwareHardware
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
5/23
Microsoft Academic Program
Student Technology Conference 2005Ziele
• WAS ?• WO ?• WIE ?
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
6/23
Microsoft Academic Program
Student Technology Conference 2005Definitionen
Performanz: “Performanz (aus engl. Performance) bezeichnet in der Informatik die Effizienz von Programmen und Hardware bezüglich des Ressourcenverbrauchs und der Qualität der Ausgabe.” [Wikipedia]
Optimierung:“Optimizing is the process of changing a program or the environment in which it runs to improve its performance.“
1. Problem identifizieren. 2. Problem evaluieren. 3. Optimierungstechnik anwenden.
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
7/23
Microsoft Academic Program
Student Technology Conference 2005Hardware
1. Speicher2. “Branch Predictions”3. Nebenläufigkeit
Itanium2 McKinley
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
8/23
Microsoft Academic Program
Student Technology Conference 20052. Profiling
Profiling:Präzise Messung (von Zeit/ Clock Ticks) von Hardware und/Software um Aussagen über das Laufzeitverhalten von Applikation treffen zu können.
1. Hardwarezähler2. Windows API and Tools3. .NET Profiling und Tools4. Demos
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
9/23
Microsoft Academic Program
Student Technology Conference 2005Hardware Counters I
• Hardware Counters
+ Sehr hohe zeitliche Auflösung•
CPU Profiling Hardware – Ereignisdetektoren (event detectors)– Ereigniszähler (event counters)
• Performanzereignisse :– Speicher – Pipeline Stalls– Brach Prediction– Ressource Utilization
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
10/23
Microsoft Academic Program
Student Technology Conference 2005Hardware Counters II
RDTSC – Read Time Stamp CounterRDPMC – Read Performance Monitor Counter
• >2 x CPU
•SpeedStep
Beispiel: RDTSC(Read Time Step Counter)
__int64 getTick(){
__int64 tmp;void *_ptr = &tmp;
_asm{rdtsc;mov ebx, _ptr;mov dword ptr[ebx], eax;mov dword ptr[ebx+4], edx;
}return tmp;
}
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
11/23
Microsoft Academic Program
Student Technology Conference 2005Windows Performance API
• Access performance counters through Windows API
• WMI - Windows Management Instrumentation
BOOL QueryPerformanceCounter( LARGE_INTEGER *lpPerformanceCount );BOOL QueryPerformanceFrequency( LARGE_INTEGER *lpPerformanceCount );
DWORD_PTR SetThreadAffinityMask( HANDLE hThread, DWORD_PTR
dwThreadAffinityMask );
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
12/23
Microsoft Academic Program
Student Technology Conference 2005.NET Profiling
PerfmonWMI
MS.NET 1.1[DllImport("Kernel32.dll")]private static extern bool QueryPerformanceCounter(out long _count);
MS.NET 2.0using System.Diagnostics;…Stopwatch _sw = new Stopwatch();_sw.Start();
do something_sw.Stop();
_sw.ElapsedTime; // TimeSpan_sw.ElapsedMilliseconds; //long_ws.ElapsedTicks; //long
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
13/23
Microsoft Academic Program
Student Technology Conference 2005.NET Profiling Services
set Cor_Enable_Profiling = 0x1set Cor_Profiler={FA0C6E77-AFF4-…992C}
COM – Schnittstellen: ICorProfilerCallbackICorProfilerInfo
CLR
_myProfilerCor_Enable_Profiling = TRUE
CoCreateInstance
ICorProfilerCallback::InitializeDemo AP
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
14/23
Microsoft Academic Program
Student Technology Conference 2005.NET 1.1. vs .NET 2.0
• SciMark • (SOR), Monte-Carlo Quadrat, Sparse Matrix Multiplikation,
LU Matrix Dekomposition
1.0 1.1
0
100
200
300
MFLOP
HW: 3.2 GHz Pentium 4 (Northwood), 1x CPU, HT disabledIntel 875P Chipset, 1 GB RAMhttp://rotor.cs.cornell.edu/SciMark
400
2.0
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
15/23
Microsoft Academic Program
Student Technology Conference 2005.NET 1.1. vs .NET 2.0
• Linpack 1000x1000
1.0 1.10
100
200
300
MFLOP
HW: 3.2 GHz Pentium 4 (Northwood), 1x CPU, HT disabledIntel 875P Chipset, 1 GB RAMhttp://rotor.cs.cornell.edu/SciMark
400
2.0Mono 1.1.3.NET 1.1 Debug
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
16/23
Microsoft Academic Program
Student Technology Conference 2005C# vs. C
HW: 2.4GHz Pentium 4, 1 GB RAM
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
17/23
Microsoft Academic Program
Student Technology Conference 2005Rotor
Microsoft Shared Source CLI - „Rotor“
• ECMA-334 (C#) • ECMA-335 (Common Language
Infrastructure)• Microsoft Windows® XP• FreeBSD
SSCLI: www.sscli.net
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
18/23
Microsoft Academic Program
Student Technology Conference 2005Zusammenfassung
• “Performance Engineering”• 1. Messen:
Sind Performanzanforderungen erfüllt?JA
• 2. NEIN: Finde langsamen Code
• Eigener Code? – Optimieren.• Framework Methode? – Weglassen, Alternative suchen.• Nicht ersetzbarer Aufruf? – Optimieren, Alternative
suchen.
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
19/23
Microsoft Academic Program
Student Technology Conference 2005
© 2003-2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
19/05/05 MS.NET – Performanzanalyse und OptimierungMatej Ciesko
20/23
Microsoft Academic Program
Student Technology Conference 2005
Mehr Informationen
• http://www.microsoft.com/perf• http://msdn.microsoft.com• http://www.thespoke.de• http://www.dotnetperformance.com/• RDTSC:
http://www.math.uwaterloo.ca/~jamuir/rdtscpm1.pdf