Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use SystemTap statistical function to execute time-consuming

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use the SystemTap statistical function to implement time-consuming, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Preface

When we need to do a system analysis of an application, we can usually use perf or flame diagrams. But these tools are usually only qualitative, and find that those functions take up a lot of cpu and need to be optimized. But there is no quantitative data, such as the time-consuming situation of this function, whether it takes 1ms or 5ms.

So instead of adding statistical time-consuming code to the code, we can use SystemTap to count the time spent of the application.

SystemTap can track kernel functions and user-mode processes, and when we track user-mode processes, we need to use its process module.

Find function symbols

In many cases, when the code is executed, its function symbol is not necessarily the name written in the code, so we can use the following script to print out the function symbol being called in the application.

Probe process ("/ data0/app") .function ("*") {println (probefunc ())}

And then execute

Stap echo.stp

It will print out each function name called by / data0/app when the program is running, and it is best to fill in the absolute path here. We can find the name of the function we need to count.

Statistical function takes time

We can use SystemTap's built-in histogram to show the time-consuming distribution. We have two histogram functions that we can use:

@ hist_linear (v, start, stop, interval) # print the histogram of the interval interval of the start-stop interval @ hist_log (v) # print the histogram of the exponential distribution based on 2

Statistics script:

Global sends # declares the global statistical storage container probe process ("/ data0/app"). Function ("git.intra.xx.send"). Return {# function is the function name and supports the wildcard character *, etc., and the time-consuming sends is calculated when the function return

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report