2014年3月12日 星期三

dvm_lock_sample @ Android event log

關於 Android event log 裡各個 log 格式定義在 
android_codebase/system/core/logcat/event.logtags

那現在要來講的是 dvm_lock_sample
dvm_lock_sample 用來表示某process的某thread為了等另一個人釋放lock,而耗了多少ms


For example:
dvm_lock_sample: [system_server,1,ActivityManager,18285,ActivityStack.java,288,ActivityManagerService.java,13056,100]
dvm_lock_sample: [system_server,1,main,16710,ActivityManagerService.java,5760,-,13056,100]
dvm_lock_sample: [system_server,1,Binder_7,15333,ActivityManagerService.java,12911,-,13056,100]
dvm_lock_sample: [system_server,0,android.bg,108,ActivityManagerService.java,1731,-,13056,21]

在 system/core/logcat/event.logtags 裡可以看到
dvm_lock_sample (process|3),(main|1|5),(thread|3),(time|1|3),(file|3),(line|1|5),(ownerfile|3),(ownerline|1|5),(sample_percent|1|6)

這後面一長串是啥鬼? 請見該檔案上方…

# Tag numbers are decimal integers, from 0 to 2^31.  (Let's leave the
# negative values alone for now.)
#
# Tag names are one or more ASCII letters and numbers or underscores, i.e.
# "[A-Z][a-z][0-9]_".  Do not include spaces or punctuation (the former
# impacts log readability, the latter makes regex searches more annoying).
#
# Optionally, after the tag names can be put a description for the value(s)
# of the tag. Description are in the format
#    (<name>|data type[|data unit])
# Multiple values are separated by commas.
#
# The data type is a number from the following values:
# 1: int
# 2: long
# 3: string
# 4: list
#
# The data unit is a number taken from the following list:
# 1: Number of objects
# 2: Number of bytes
# 3: Number of milliseconds
# 4: Number of allocations
# 5: Id
# 6: Percent
# Default value for data of type int/long is 2 (bytes).


對照一下 dvm_lock_sample…
(process|string),(main|int|id),(thread|string),(time|int|ms),(file|string),(line|int|id),(ownerfile|string),(ownerline|int|id),(sample_percent|int|%)

好吧,我知道還是有些亂…對照一下例子好了…

dvm_lock_sample: [system_server,1,ActivityManager,108,ActivityStack.java,288,-,13056,100]

(process|string)       system_server (process name)
(main|int|id)          1 (yes)
(thread|string)        ActivityManager (thread name)
(time|int|ms)          108 (lock time 單位:ms)
(file|string)          ActivityStack.java (file name)
(line|int|id)          288 (對應 file 的行數)
(ownerfile|string)     - (owner file name,- 表示和 file name 一樣)
(ownerline|int|id)     13056 (對應 owner file 的行數)
(sample_percent|int|%) 21 (lock time/500的百分比,佔用500ms以上皆為100%)

沒有留言:

張貼留言