Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Wrong power measurement on iPad 2020 #3

Open
hamjin opened this issue May 30, 2023 · 21 comments
Open

Bug: Wrong power measurement on iPad 2020 #3

hamjin opened this issue May 30, 2023 · 21 comments
Assignees
Labels
bug Something isn't working

Comments

@hamjin
Copy link

hamjin commented May 30, 2023

Version: 2.3.0
Device: iPad 8
iPad OS Version: 16.5
SoC: Apple A12

Steps to reproduce

Open the app first. Then select one of the project and run.
I'm sure that the device is not charging or doing anything else.

Expected behaviour

Show correct power.

Actual behaviour

Always showing wrong power like below.
70c9df81a318756493dc24d139cd0b0b_720
ca3d3a1c251ae3744118c8eff4254d0f
5ead7f6049d6115dac9df0d6149ac09e

@junjie1475
Copy link
Owner

First, thanks for opening up an issue. The power measurement is from apple's CLPC(Close loop performance controller)which I believe only appear on SoC >A13. I used this to get high resolution per process energy consumption; so under current circumstances, there is no way to workaround with this. Maybe there are other ways to get this but I am sure it wouldn't be as accurate as the current approach.

@junjie1475 junjie1475 added the bug Something isn't working label May 30, 2023
@junjie1475 junjie1475 self-assigned this May 30, 2023
@hamjin
Copy link
Author

hamjin commented May 30, 2023

IOService.txt
10dcd07be4428d66df948e6bc3b80b57
62431c6e6ac73144c80b9945df4bca99
It's clear that Apple A12 has CLPC

@junjie1475
Copy link
Owner

From XNU source code(Version 8792.81.2), the power energy counter code is gated behind macro HAS_CPU_DPE_COUNTER, and apple had only published the header(see https://github.com/apple-oss-distributions/xnu/blob/5c2921b07a2480ab43ec66f5b9e41cb872bc554f/pexpert/pexpert/arm64/H13.h#L50) for H13(A14) which defineds that macro; I don't really know if there is another way to get those header file(after Version 8792.81.2).

@hamjin
Copy link
Author

hamjin commented May 30, 2023

Can you can provide a power calibration interface like GPU GFLOPS? I think that helps with debugging.

@junjie1475
Copy link
Owner

Can you can provide a power calibration interface like GPU GFLOPS? I think that helps with debugging.

If you mean high resolution sampling, see my another repo https://github.com/junjie1475/ios_power_log

@TomyLemon
Copy link
Collaborator

Can you can provide a power calibration interface like GPU GFLOPS? I think that helps with debugging.

Do you mean a power measure app with GUI and run in the background ?

@hamjin
Copy link
Author

hamjin commented May 31, 2023

Can you can provide a power calibration interface like GPU GFLOPS? I think that helps with debugging.

If you mean high resolution sampling, see my another repo https://github.com/junjie1475/ios_power_log

I think it may be a wrong unit of measurement causing the power to show extremely low.

@hamjin
Copy link
Author

hamjin commented May 31, 2023

Can you can provide a power calibration interface like GPU GFLOPS? I think that helps with debugging.

Do you mean a power measure app with GUI and run in the background ?

If you can, that's great.

@junjie1475
Copy link
Owner

junjie1475 commented May 31, 2023

Can you can provide a power calibration interface like GPU GFLOPS? I think that helps with debugging.

If you mean high resolution sampling, see my another repo https://github.com/junjie1475/ios_power_log

I think it may be a wrong unit of measurement causing the power to show extremely low.

From XNU documentation(see recount.md) the unit is nano-joule, but you can try to use ios_power_log to track the energy consumption/sec and see what cause the bug.

@junjie1475
Copy link
Owner

Can you can provide a power calibration interface like GPU GFLOPS? I think that helps with debugging.

Do you mean a power measure app with GUI and run in the background ?

If you can, that's great.

I don't think it's possible to track other process's info on iOS but I can integrate the graph into the App itself perhaps(Maybe through swift chart).

@hamjin
Copy link
Author

hamjin commented May 31, 2023

Can you can provide a power calibration interface like GPU GFLOPS? I think that helps with debugging.

If you mean high resolution sampling, see my another repo https://github.com/junjie1475/ios_power_log

I think it may be a wrong unit of measurement causing the power to show extremely low.

From XNU documentation(see recount.md) the unit is nano-joule, but you can try to use ios_power_log to track the energy consumption/sec and see what cause the bug.

Sorry but I don't have a computer running macOS.

@junjie1475
Copy link
Owner

Can you can provide a power calibration interface like GPU GFLOPS? I think that helps with debugging.

If you mean high resolution sampling, see my another repo https://github.com/junjie1475/ios_power_log

I think it may be a wrong unit of measurement causing the power to show extremely low.

From XNU documentation(see recount.md) the unit is nano-joule, but you can try to use ios_power_log to track the energy consumption/sec and see what cause the bug.

Sorry but I don't have a computer running macOS.

You don't need to have one, as far as I know you can use sideloadly to inject the dylib and it is also possible to read console log through windows.

@TomyLemon
Copy link
Collaborator

Can you can provide a power calibration interface like GPU GFLOPS? I think that helps with debugging.

If you mean high resolution sampling, see my another repo https://github.com/junjie1475/ios_power_log

I think it may be a wrong unit of measurement causing the power to show extremely low.

In my opinion, it seems right. As you can see, the power measured by the app is slightly lower than the power measured by macOS powermetrics command.
Screenshot 2023-05-31 at 10 28 12 PM
This command shows the cpu power, while our app measures the spec2017 task power, so it will be a bit lower.

@asto18089
Copy link

Can you can provide a power calibration interface like GPU GFLOPS? I think that helps with debugging.

If you mean high resolution sampling, see my another repo https://github.com/junjie1475/ios_power_log

I think it may be a wrong unit of measurement causing the power to show extremely low.

In my opinion, it seems right. As you can see, the power measured by the app is slightly lower than the power measured by macOS powermetrics command. Screenshot 2023-05-31 at 10 28 12 PM This command shows the cpu power, while our app measures the spec2017 task power, so it will be a bit lower.

Yes, but I believe he uses Apple A12 but not Apple M1, something could be different for that chip.

I agree with junjie that the difference could reside in differences between Apple A12's CLPC and Apple M1's CLPC, and in XNU opensource only M1's CLPC definition could be found, so a headache here......

@hamjin
Copy link
Author

hamjin commented Jun 4, 2023

697799afd74fbe72f93ddd01caf06ed0
image
This is a section of my running 500.perlbench results (from rest to running), without power saving mode enabled

@junjie1475
Copy link
Owner

697799afd74fbe72f93ddd01caf06ed0

image

This is a section of my running 500.perlbench results (from rest to running), without power saving mode enabled

I am not very sure what is the power usage of the A12 device but it seems like power x100 would lead to the correct result.

@hamjin
Copy link
Author

hamjin commented Jun 4, 2023

697799afd74fbe72f93ddd01caf06ed0
image
This is a section of my running 500.perlbench results (from rest to running), without power saving mode enabled

I am not very sure what is the power usage of the A12 device but it seems like power x100 would lead to the correct result.

image
Only one result from Anandtech's Spec 2006 has subitem power consumption and I don't know the gap.

@junjie1475
Copy link
Owner

junjie1475 commented Jun 4, 2023 via email

@hamjin
Copy link
Author

hamjin commented Jun 4, 2023

Ok then, I will patch this fix when I have time.

On Sun, 4 Jun 2023 at 5:59 PM, hamjin @.> wrote: [image: 697799afd74fbe72f93ddd01caf06ed0] https://user-images.githubusercontent.com/30927889/243166013-5a79d08a-c4bd-4655-acfe-5997a60dfb77.png [image: image] https://user-images.githubusercontent.com/30927889/243166045-6bcfe3f1-6840-4f8a-a2dd-a78a9abe4491.png This is a section of my running 500.perlbench results (from rest to running), without power saving mode enabled I am not very sure what is the power usage of the A12 device but it seems like power x100 would lead to the correct result. [image: image] https://user-images.githubusercontent.com/30927889/243168910-07037421-8ec5-4918-a012-8e933be76dec.png Only one result from Anandtech's Spec 2006 has subitem power consumption and I don't know the gap. — Reply to this email directly, view it on GitHub <#3 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUSI37B22TRVINESQ5HO7E3XJRL6PANCNFSM6AAAAAAYTNW6QA . You are receiving this because you were assigned.Message ID: @.>

image
Sorry, the power measured in the Geekbench 6 multi-core test does not support previous guesses. Either ri_penergy nj ("power" in the picture) or ri energy nj` ("power" in the picture) may be incorrect on the Apple A12 or have other reasons. Maybe we have to collect more information about this SoC.

@junjie1475
Copy link
Owner

Ok then, I will patch this fix when I have time.

On Sun, 4 Jun 2023 at 5:59 PM, hamjin @.> wrote: [image: 697799afd74fbe72f93ddd01caf06ed0] https://user-images.githubusercontent.com/30927889/243166013-5a79d08a-c4bd-4655-acfe-5997a60dfb77.png [image: image] https://user-images.githubusercontent.com/30927889/243166045-6bcfe3f1-6840-4f8a-a2dd-a78a9abe4491.png This is a section of my running 500.perlbench results (from rest to running), without power saving mode enabled I am not very sure what is the power usage of the A12 device but it seems like power x100 would lead to the correct result. [image: image] https://user-images.githubusercontent.com/30927889/243168910-07037421-8ec5-4918-a012-8e933be76dec.png Only one result from Anandtech's Spec 2006 has subitem power consumption and I don't know the gap. — Reply to this email directly, view it on GitHub <#3 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUSI37B22TRVINESQ5HO7E3XJRL6PANCNFSM6AAAAAAYTNW6QA . You are receiving this because you were assigned.Message ID: @.>

image

Sorry, but power measurements on Geekbench 6 don't support previous guesses. Either ri_penergy nj ("power" in the picture) or ri energy nj` ("power" in the picture) may be incorrect on the Apple A12 or have other reasons. Maybe we have to collect more information about this SoC.

I think it is possible that those values don't have any meaning. I should look more into the XNU code to see if I can find more clues.

@hamjin
Copy link
Author

hamjin commented Jun 4, 2023

Thanks again for your efforts, if help is needed I will do my best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants