当前位置: 首页 > news >正文

四川省网站建设_网站建设公司_jQuery_seo优化

网站的种类有哪些,做悬赏的网站,信息流投放,开发公司与物业服务合同范本引言#xff1a;好久没分享了#xff0c;不多废话了#xff0c;准备一个专题分三期来分享下golang的性能分析。O 专题目标理解profile基本原理熟悉go常用性能分析工具pprof快速对线上服务的cpu、内存、goroutine的问题进行分析和排查对性能分析#xff0c;golang是采取采样…引言好久没分享了不多废话了准备一个专题分三期来分享下golang的性能分析。O 专题目标理解profile基本原理熟悉go常用性能分析工具pprof快速对线上服务的cpu、内存、goroutine的问题进行分析和排查 对性能分析golang是采取采样分析的方式语言原生支持对运行的程序进行采样收集采样数据通过累加计算并通过提供相应的工具来分析堆栈信息。【对比javajava通过发布jdk周边工具jps jmap jstack等在问题分析前先将内存中的数据进行dump的方式进行分析】一 profile原理A Profile is a collection of stack traces showing the call sequences that led to instances of a particular event, such as allocation. Packages can create and maintain their own profiles; the most common use is for tracking resources that must be explicitly closed, such as files or network connections. go默认会初始化六种profile, 每种profile存储的实际内容被抽象为 ​countProfile​,存储栈帧地址堆栈地址通过调用​runtime.CallersFrames(stk)​可以获取堆栈信息下面主要讲最常用的三种方式内存、CPU和协程type countProfile interface { Len() int Stack(i int) []uintptr}// A countProfile is a set of stack traces to be printed as counts grouped by stack trace. There are multiple implementations:all that matters is that we can find out how many traces there are and obtain each trace in turn.内存采样 go程序启动后runtime会按照一定频率对内存的分配进行采样记录当内存分配每达到一定值(默认是512KB参数由​runtime.MemProfileRate​设定), runtime就会记录下当前这次内存分配的大小、stack等信息到profiletype MemProfileRecord struct { AllocBytes, FreeBytes int64 // number of bytes allocated, freed AllocObjects, FreeObjects int64 // number of objects allocated, freed Stack0 [32]uintptr // stack trace for this record; ends at first 0 entry}CPU采样 cpu的采样是通过调用函数​StartCPUProfile​来启动采样的结束调用​StopCPUProfile​调用链如下StartCPUProfile​-​runtime.SetCPUProfileRate​-​sighandler​采样频率是100hz// The runtime routines allow a variable profiling rate,// but in practice operating systems cannot trigger signals// at more than about 500 Hz, and our processing of the// signal is not cheap (mostly getting the stack trace).// 100 Hz is a reasonable choice: it is frequent enough to// produce useful data, rare enough not to bog down the// system, and a nice round number to make it easy to// convert sample counts to seconds. Instead of requiring// each client to specify the frequency, we hard code it.const hz 100// readProfile, provided by the runtime, returns the next chunk of// binary CPU profiling stack trace data, blocking until data is available.// If profiling is turned off and all the profile data accumulated while it was// on has been returned, readProfile returns eoftrue.// The caller must save the returned data and tags before calling readProfile again.func readProfile() (data []uint64, tags []unsafe.Pointer, eof bool)goroutine采样 GMP模型中G goroutine P context M thread采样数据来源于P运行中的协程上下文堆栈。P会维护当前执行队列队列中是M对应的G队列。自行检索GPM原理(关键字窃取、61分之一全局队列)如何将采样内容汇总 假设我们在程序执行的某个时刻取样得到一个栈帧序列是ABC可以得到的信息包括此刻运行的函数是C是从函数B调用到C的。当取样很多次后进行统计就可以得到调用的信息。比如对下面这段代码的取样void A() { B(); for (int i0; i3; i) C(); } void B() { for (int i0; i5; i) C(); }将得到A AB ABC ABC ABC AC 根据统计信息: 函数累加耗时和调用关系根据这些数据可以构造有向图profiles采样后会以pprof-formatted格式存储起来分析这些数据需要用到golang的分析工具。下一节分享golang常用的分析工具敬请期待。欢迎关注大龄码农
http://www.ihoyoo.com/news/1078.html

相关文章:

  • 电商网站开发平台哪家好网站qq在线状态
  • 南山网站建设公司乐云seowordpress 显示用户昵称
  • 中国制造网网站建设的优势房地产新闻联播
  • 公司办公网络设计方案山西seo优化公司
  • 肃宁县做网站做淘客必须有自己内部网站吗
  • 高端网站名字电商网站开发报告
  • 网页设计个人网页代码沈阳网站关键词优化做的好吗
  • 百度做网站推广多少钱上海公司注册网上核名
  • 安卓盒子 做网站wordpress新浪微博图床
  • 与企业网站做接口运营策划
  • 长沙专业网站制作wordpress主题在哪
  • phpcms 安装官网的教程更换域名后网站图片还是无法显示wordpress导出xml
  • 个人网站设计模板上海天华建筑设计有限公司代表作
  • wordpress回收站在哪wordpress皮肤
  • 在线做试卷的网站重庆网站seo排名
  • 网上家教网站开发阿里云建设网站
  • 在网站上发消息做宣传装修在线设计平台
  • 用.net core 做网站网络营销包括哪些基本内容
  • 自己买服务器可以搭建网站吗福州制作网站软件
  • 百度免费网站空间备案 网站名称 怎么改
  • 江西工程建设信息网站网站持有者和备案企业
  • 北京网站制作公司公司湖南专业seo推广
  • 以什么主题做网站好网站制作编辑软件
  • angular wordpressseo搜索优化公司报价
  • 建网站的公司南京学习网站建设的心得体会
  • 太平洋在线企业网站管理系统南阳做网站
  • 怎么做卖花的网站西安市建设工程信息网平台官网
  • 比较有名的diy制作网站什么是网络营销网络营销的内容有哪些
  • 什邡移动网站建设网站备案取消接入
  • 获得网站后台地址深圳蕾奥规划设计公司网站