Skip to content

Necessary Changes to Deploy MemPerf on Android Platforms #7

@zhoujinzhoujin

Description

@zhoujinzhoujin

Based on my investigation, MemPerf can run on Android platforms after some code modifications.
First, the rdtscp() implementation should be changed. Answers in https://stackoverflow.com/questions/40454157/is-there-an-equivalent-instructionto-rdtsc-in-arm/40455065 provide some solution ideas.
Second, the dlsym() function to help intercept malloc, free, pthread_create, locks, and system calls also works on Android. However, there are public and private .so files in android, and dlsym() can only read symbols from public libraries. The interception part will work fine if the related libraries are public, or using alternative ways (like binary instrumentation)
Third, Android also has perf_event_open() function to utilize PMU. The work https://android.googlesource.com/platform/prebuilts/simpleperf/+/refs/heads/ndk-r13-release/README.md is very similar to perf, and it is for Android platforms. It supports both "perf stat" (PMU counting) and "perf record" (PMU sampling) commands.
Fourth, Android does not support backtrace() function, so it should be replaced with alternative implementations. https://stackoverflow.com/questions/8115192/android-ndk-getting-the-backtrace shows some solutions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions