google / perfetto

Performance instrumentation and tracing for Android, Linux and Chrome (read-only mirror of https://android.googlesource.com/platform/external/perfetto/)
https://www.perfetto.dev
Apache License 2.0
2.81k stars 350 forks source link

android 13 perfetto no data,I list config below ,want to get some help here~ #698

Closed 20083017 closed 8 months ago

20083017 commented 8 months ago

log

nuwa:/data/local/tmp # ./perfetto -c 1.perfetto.config --txt --out /data/misc/1
[916.276]    [perfetto_cmd.cc:1080](http://perfetto_cmd.cc:1080/) Connected to the Perfetto traced service, TTL: 30s
[946.287]    [perfetto_cmd.cc:1242](http://perfetto_cmd.cc:1242/) Wrote 17974 bytes into /data/misc/1

config

buffers: {
    ## 将buffer增大1000倍,否则出现Perfetto ui解析出错
    size_kb: 63488000
    fill_policy: DISCARD
}
buffers: {
    size_kb: 63488000
    fill_policy: DISCARD
}
data_sources: {
    config {
        name: "android.packages_list"
        target_buffer: 1
    }
}
data_sources: {
    config {
        name: "android.heapprofd"
        target_buffer: 0
        heapprofd_config {
            sampling_interval_bytes: 4096
            process_cmdline: "com.xiaomi.mi_connect_service:idm"
            shmem_size_bytes: 8388608
            heaps: "com.android.art"
            continuous_dump_config {
                ## 10s之后,才开始第一次dump
                dump_phase_ms: 10000
                ## 每隔2s,dump一次
                dump_interval_ms: 2000
            }
        }
    }
}

data_sources: {
    config {
        name: "android.java_hprof"
        target_buffer: 0
        java_hprof_config {
            process_cmdline: "com.xiaomi.mi_connect_service:idm"
            continuous_dump_config {
                ## 10s后,才开始第一次dump
                dump_phase_ms: 10000
                ## 每隔2s,dump一次
                dump_interval_ms: 2000
            }
        }
    }
}
## 总时间变成 30s
duration_ms: 30000
ddiproietto commented 8 months ago

I can see a couple of problems with this:

  1. The buffer sizes are too big. The total buffer size (in bytes) should be less than 32-bit. On android 14, perfetto will emit a better error message, but on android 13, if the total buffer size is too big, you might get a smaller buffer than you expect. You do not need a buffer this big. I would start with a config generated by ./tools/java_heap_dump and ./tools/heap_profile.
  2. Do you have permissions to profile "com.xiaomi.mi_connect_service:idm"?. On a userdebug build, you should. On a user build, you can get profiling data only from profileable and debuggable apps. (See https://perfetto.dev/docs/data-sources/native-heap-profiler#heapprofd-targets).

Let me know if you have other questions.