Skip to content

Conversation

@jmr
Copy link
Member

@jmr jmr commented Aug 24, 2023

This works around some performance problems running Android under QEMU. Calling pfm_initialize was very slow, and was called during dynamic initialization (before main or when loaded as a shared library). This happened whenever benchmark was linked, even if no benchmarks were run.

Instead, call pfm_initialize at most once, and only when one of:

  1. PerfCounters::Initialize is called
  2. PerfCounters::Create is called with a non-empty counter list
  3. PerfCounters::IsCounterSupported is called

The return value of the first pfm_initialize() is saved and returned from all subsequent PerfCounters::Initialize calls.

jmr added 2 commits August 24, 2023 07:29
This works around some performance problems running Android under QEMU.
Calling `pfm_initialize` was very slow, and was called during dynamic
initialization (before `main` or when loaded as a shared library).
This happened whenever benchmark was linked, even if no benchmarks
were run.

Instead, call `pfm_initialize` at most once, and only when one of:
1. `PerfCounters::Initialize` is called
2. `PerfCounters::Create` is called with a non-empty counter list
3. `PerfCounters::IsCounterSupported` is called

The return value of the first `pfm_initialize()` is saved and
returned from all subsequent `PerfCounters::Initialize` calls.
@jmr
Copy link
Member Author

jmr commented Aug 24, 2023

@mtrofin

@dmah42 dmah42 merged commit 9c65aeb into google:main Aug 24, 2023
@dmah42
Copy link
Member

dmah42 commented Aug 24, 2023

thanks!

@jmr jmr deleted the perf-counter-init branch August 24, 2023 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants