持续性能剖析数据说明

持续性能剖析数据存储在用户名下的SLS中(SLS Project:proj-xtrace-<encode>-<region-id>,SLS Logstore:logstore-profiling)。本文介绍持续性能剖析的日志数据格式。

日志数据

字段

类型

说明

示例

aggTypes

String

聚合方式。

sum

dataType

String

数据格式。

CallStack

durationNs

Long

一次Profile过程持续的时间。单位:纳秒。

10000000000

labels

JSON

标签信息。

{"ip" : "10.10.10.10"}

language

String

语言类型。

go

name

String

栈顶名,精确到函数名。

runtime.allocm /usr/local/go/src/runtime/proc.go

profileID

String

此次Profile生成的UUID。

c3869101-8e6c-43a8-803e-f11b14a30cfe

stack

String

调用关系,从栈第二层到栈底。

runtime.newm /usr/local/go/src/runtime/proc.go

runtime.startm /usr/local/go/src/runtime/proc.go

runtime.handoffp /usr/local/go/src/runtime/proc.go

runtime.stoplockedm /usr/local/go/src/runtime/proc.go

runtime.schedule /usr/local/go/src/runtime/proc.go

runtime.goschedImpl /usr/local/go/src/runtime/proc.go

runtime.gopreempt_m /usr/local/go/src/runtime/proc.go

runtime.newstack /usr/local/go/src/runtime/stack.go

runtime.morestack /usr/local/go/src/runtime/asm_amd64.s

stackID

String

标识唯一的调用栈,可用于统计不同调用栈方法的执行时间。

70376ab5b5ad88ddadb51b6dfd4c486a

type

String

Profile类型

profile_mem

units

String

值的单位。

bytes

val

Double

函数自身占用值。

10000000.00

valueTypes

String

值的类型。

cpu

Profile类型

Profile类型、值的类型、值的单位之间的对应关系如下表所示。

Profile类型

属性

单位

含义

profile_cpu

cpu

nanoseconds

CPU执行耗时。

profile_wall_clock

wall_clock

nanoseconds

实际执行耗时。

profile_mem

alloc_in_new_tlab_bytes

bytes

创建新TLAB内对象空间。

profile_mem

alloc_in_new_tlab_objects

count

创建新TLAB内对象大小。

profile_mem

alloc_outside_tlab_bytes

bytes

创建新TLAB外对象空间。

profile_mem

alloc_outside_tlab_objects

count

创建新TLAB外对象大小。

profile_goroutines

goroutines

count

Go协程使用情况。

profile_block

block_count

count

阻塞分析,等待共享资源的次数。

profile_block

block_duration

nanoseconds

阻塞分析,等待共享资源花费的时间。

profile_mutex

mutex_count

count

互斥锁分析,锁定次数。

profile_mutex

mutex_duration

nanoseconds

互斥锁分析,锁定时间。

  • CPU:CPU执行代码块所花费的时间。测量线程在CPU上实际执行指令的时长,不包括线程阻塞、切换或者IO等待的时间。通过profile_cpu的数据,可以定位计算密集型的热点代码,发现CPU使用率过高的性能瓶颈。属性:cpu,单位:nanoseconds。

  • MEM:代码块执行过程中的内存分配情况。包括线程本地缓冲区(TLAB)内的对象分配(alloc_in_new_tlab_bytes/objects)和TLAB外的堆内存分配(alloc_outside_tlab_bytes/objects)。通过分析内存使用模式,可以发现内存泄漏、优化GC性能,确保应用内存使用合理。单位:bytes(内存空间)和count(对象数量)。

  • WALLCLOCK:代码块的实际执行时间,从开始到结束的全部时长。包括CPU执行时间以及线程阻塞、IO等待、锁竞争等各种暂停的时间。wall_clock反映了用户实际感知到的性能,总是大于等于CPU时间。属性:wall_clock,单位:nanoseconds。

  • GOROUTINE:Go协程使用情况。记录goroutine的创建、调度和销毁等信息,帮助发现并发问题如goroutine泄漏、调度性能瓶颈等。通过分析goroutine的行为可以优化并发程序的性能。属性:goroutines,单位:count。

  • BLOCK:代码块在执行过程中的阻塞情况。记录等待共享资源的次数(block_count)和总等待时间(block_duration)。通过分析阻塞数据,可以发现资源竞争热点,优化并发访问模式,避免性能瓶颈。单位:count(次数)和nanoseconds(时间)。

  • MUTEX:互斥锁的使用情况。记录获取锁的次数(mutex_count)和持有锁的总时间(mutex_duration)。通过分析锁的使用模式,可以发现锁竞争问题,优化并发设计,提高程序的并发性能。单位:count(次数)和nanoseconds(时间)。