Skip to content

[ADPF] PerformanceHintAPI - include core threads + use NDK API - #16610

Merged
minggo merged 7 commits into
cocos:v3.8.3from
HakimHauston:hakim/v3.8.3-adpf
Dec 28, 2023
Merged

minggo merged 7 commits into
cocos:v3.8.3from
HakimHauston:hakim/v3.8.3-adpf

Conversation

@HakimHauston

Copy link
Copy Markdown
Contributor

Re: #

adapt PerformanceHintAPI to include main thread & render thread and optionally use the NDK API when available

Changelog

  • Add call to ADPF Performance Hint Manager in MessageQueue
  • Adapt ADPFManager to be able to dynamically add/remove thread-ids

Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • [ V] does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@github-actions

Copy link
Copy Markdown

Interface Check Report

This pull request does not change any public interfaces !

Comment thread native/cocos/base/threading/MessageQueue.cpp Outdated
Comment thread native/cocos/base/threading/MessageQueue.cpp Outdated
@minggo

minggo commented Dec 18, 2023

Copy link
Copy Markdown
Contributor

Please refer the compiling error on Android

 /home/runner/work/cocos-engine/cocos-engine/native/cocos/base/threading/MessageQueue.cpp:284:5: error: use of undeclared identifier 'ADPFManager'
      ADPFManager::getInstance().AddThreadIdToHintSession(tid);

Comment thread native/cocos/platform/android/adpf_manager.cpp Outdated
@minggo

minggo commented Dec 22, 2023

Copy link
Copy Markdown
Contributor

Could you please fix the clang tidy error?

Comment thread native/cocos/platform/android/adpf_manager.cpp Outdated
Comment thread native/cocos/platform/android/adpf_manager.cpp Outdated
Comment thread native/cocos/platform/android/adpf_manager.cpp
Comment thread native/cocos/platform/android/adpf_manager.cpp Outdated
}
void ADPFManager::AddThreadIdToHintSession(int32_t tid) {
thread_ids_.push_back(tid);
auto data = thread_ids_.data();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems data is not used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaned up in 1d6c8b9


void ADPFManager::RemoveThreadIdFromHintSession(int32_t tid) {
thread_ids_.erase(std::remove(thread_ids_.begin(), thread_ids_.end(), tid), thread_ids_.end());
auto data = thread_ids_.data();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaned up data in 1d6c8b9

Comment thread native/cocos/platform/android/adpf_manager.cpp
#elif __ANDROID_API__ >= 33
auto data = thread_ids_.data();
std::size_t size = thread_ids_.size();
int result = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems result is only used in CC_LOG_INFO ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaned up variables in 1d6c8b9

jobject obj_power_service_;
jmethodID get_thermal_headroom_;

std::map<std::string, jobject> map_hint_sessions;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use std::unordered_map<> if the order is not important.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, order isn't important, only the key value mapping is, changed in 1d6c8b9

@minggo

minggo commented Dec 26, 2023

Copy link
Copy Markdown
Contributor

@HakimHauston thanks, i will merge it after @HakimNB approve it.

@HakimNB

HakimNB commented Dec 26, 2023

Copy link
Copy Markdown

@HakimHauston thanks, i will merge it after @HakimNB approve it.

Thanks.. but I am not authorized to approve it..?

@minggo

minggo commented Dec 27, 2023

Copy link
Copy Markdown
Contributor

@HakimNB i am not sure, i thought everyone had the permission. But no matter, you can reply in comment if you approve it.

@HakimNB HakimNB left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minggo approved

@minggo
minggo merged commit 716b935 into cocos:v3.8.3 Dec 28, 2023
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.

3 participants