Cloud Wisdom Perspective treasure. NET Code performance monitoring implementation principle

Source: Internet
Author: User

one,. NET Platform and status

1 ,. NET

. NET Framework is a multilingual component development and execution environment that provides a unified programming environment across languages, including: C #, VB, C + + (CLI), J #, and more.

. NET provides a programming model for creating HTML pages, called ASP., and there are many programming models in the ASP: such as MVC, WebAPI, WebForm, and so on.

. NET Schema Model diagram

This picture basically describes. NET's platform architecture.

2 , platform and open source (painful to say)

Applications written prior to. NET 2015 can only run on Windows platforms, and if you want to move values to Linux, you can only rely on the open source Framework (Mono) and need to recompile.

In accordance with the. NET Development roadmap published by Microsoft at the 2015 Build conference, applications written in. NET Core in 5.0 and later will be deployed and run directly across platforms, eliminating the need for recompilation.

The official version of 5.0 will be officially released in spring 2016 and is now available for Beta 7 (released on September 2, 2015), and the significance of this version is the first time it has been implemented. NET programs can run on Mac and Linux without relying on mono.

Microsoft has put. NET platform in addition to form core open source (8 years after Java Open Source, Microsoft has finally taken a difficult step, but the road to go a long way)

Microsoft is right. NET platform for a new build.

3 , Basic Concepts

CLR (Common Language Runtime, universal language runtime)

Like a Java virtual machine. It is the run-time environment for. NET applications, which is responsible for resource management (memory allocation and garbage collection, etc.) of the program and the necessary separation between the application and the underlying operating system.

MSIL (Microsoft intermediate Language, Microsoft intermediate language)

Il is an intermediate language derived from the Microsoft. NET platform, and compilers of various high-level languages (such as c#,vb,f#) on the. NET platform convert their textual representations to IL. A variety of different text forms are eventually unified to the way IL is expressed, including. NET platform, such as "Paradigm", "Class", "Interface", "module", "Property" and so on.

JIT (Just in Time, instant compilation)

When an app written in a high-level language is compiled to IL, the JIT compiler compiles the IL as a local instruction and executes it to maximize platform independence.

. NET Platform framework has a natural cross-platform advantage, but Microsoft has made it a unique version of the Windows platform, and fortunately he is now taking the first step in open source and cross-platform.

Second, the perspective of the treasure. NET application performance monitoring implementation and principle

1 , Fundamentals

. NET applications are compiled into IL, and they are usually packaged as files with the suffix ". dll", which are dynamically linked libraries that contain application metadata, IL, and program link information, and JIT compiles the Il language in these DLLs to convert them into machine-executable machine codes.

Before JIT compiles IL for the first time, our. NET Agent intercepts and overwrites the IL and injects the probe, intercepts the method execution, grabs the program run stack, and collects the application context data (including any desired data such as SQL).

2 ,. NET Profiling Agent Implementation

The perspective treasure. NET Agent consists of two parts:

(1), Probe injection core components

It is a component written in the C + + language. Can theoretically be attached to anything you want to intercept. NET application runtime Environment, including ASP. NET desktop applications and service, or even the mobile app of Windows Phone), which is responsible for IL rewriting and will only execute once before any method is JIT, and will no longer execute once execution is complete.

probe injection core components require efficiency, stability, and security, because any overwrite errors and errors in IL can cause the entire application to crash .

(2), probe

The probe is a set of methods that mainly accomplish the collection of contextual data, including the data collected by the perspective treasure, such as stacks, SQL, APIs, and so on.

This is a schematic diagram of the. NET Profiling agent implementation, and the green part of the figure is the two levels that the. NET Profiling agent exists.

(3), for example (we are still from the constant Hello world! Program start)

SOURCE program:

After compiling:

Instrumented IL:

Third, installation and deployment

The perspective treasure. NET Profiling Agent follows the standard development specification for Smart Agent components, and is also very simple to configure and install, requiring only a. bat file to be executed and not affected by the application and machine restarts, as long as it persists after installation.

This is the installation life cycle flowchart of the. NET agent, and the dark blue part of the figure is the part where manual intervention is required, and the others are done automatically.

The above is the cloud wisdom perspective treasure. NET Code monitoring implementation principles and deployment methods, in addition to the perspective Bao also support the main web language such as PHP, Java, Python monitoring, in a single request tracking to provide detailed tracking of code execution, including: see the execution of the slowest 10 elements, including the number of elements executed, Duration and percentage of elapsed time; View the HTTP request parameters, including the response status of the request, the link page, the specific request parameters, and the return result; View detailed tree information for the code execution stack, including the calculation time for each method, total time spent and number of calls, the slowest way you can see the special identity directly ; View the total time-consuming ordering of SQL statements, including total SQL execution time, number of executions, and specific query statements.

At present, the standard version of the perspective Bao APM free of charge, the Enterprise version provides 30-day free trial, the need for developers and maintenance students can visit the perspective Bao official website: http://toushibao.com/, apply for registration.


Cloud Wisdom Perspective treasure. NET Code performance monitoring implementation principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.