Skip to content

Conversation

noahsmartin
Copy link
Contributor

@noahsmartin noahsmartin commented Jul 31, 2025

The data being reported here was CPU time, not energy (in joules) despite the API request claiming it was reporting joules. This led to invalid data being displayed on the frontend, the UI would say it was graphing watts, but it wasn't actually. You could see this by writing CPU intensive code (I used a simd operation) on a userInitiated queue and comparing it to the same operation on a background queue. Here's the result from my test app before this change on a userInitiatedQueue:

Screenshot 2025-07-31 at 9 42 47 AM

and on a background queue:
Screenshot 2025-07-31 at 9 43 48 AM

The shape is the same, and neither show reasonable numbers for watts (< 0.1W). The shape is the same because about the same amount of CPU time is used, one was just expected to draw more power.

With this fix the graph looks much better and you can clearly see the difference that a userInitiated and background queue make on energy consumption:
Screenshot 2025-07-31 at 9 46 20 AM

Screenshot 2025-07-31 at 9 46 43 AM

@noahsmartin noahsmartin force-pushed the fixEnergyReporting branch 2 times, most recently from 6a5ecbf to 2bdbafa Compare July 31, 2025 14:08
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.703%. Comparing base (0b5fd21) to head (a61aad4).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #5768       +/-   ##
=============================================
+ Coverage   86.568%   86.703%   +0.135%     
=============================================
  Files          423       423               
  Lines        36310     36333       +23     
  Branches     15473     17103     +1630     
=============================================
+ Hits         31433     31502       +69     
+ Misses        4837      4550      -287     
- Partials        40       281      +241     
Files with missing lines Coverage Δ
SentryTestUtils/TestSentrySystemWrapper.swift 100.000% <ø> (ø)
Sources/Sentry/SentryDependencyContainer.m 88.073% <ø> (ø)
Sources/Sentry/SentryMetricProfiler.m 97.969% <100.000%> (+0.020%) ⬆️
Sources/Sentry/SentrySystemWrapper.mm 66.216% <100.000%> (ø)

... and 49 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b5fd21...a61aad4. Read the comment docs.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Thank you @noahsmartin.

Copy link
Contributor

github-actions bot commented Jul 31, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1245.12 ms 1263.08 ms 17.96 ms
Size 23.75 KiB 912.77 KiB 889.02 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
bce9765 1229.42 ms 1243.49 ms 14.07 ms
8ad303c 1220.02 ms 1231.79 ms 11.77 ms
e64d3d4 1241.90 ms 1260.10 ms 18.20 ms
42cfd79 1222.13 ms 1244.23 ms 22.10 ms
9e0030e 1222.78 ms 1242.23 ms 19.45 ms
5aa3ce5 1222.78 ms 1245.39 ms 22.61 ms
f92cfa9 1217.94 ms 1240.06 ms 22.12 ms
63ac649 1192.10 ms 1216.78 ms 24.68 ms
efab7d3 1219.98 ms 1252.12 ms 32.14 ms
d3f650a 1225.45 ms 1241.86 ms 16.41 ms

App size

Revision Plain With Sentry Diff
bce9765 23.74 KiB 874.06 KiB 850.32 KiB
8ad303c 23.75 KiB 879.24 KiB 855.49 KiB
e64d3d4 23.75 KiB 855.37 KiB 831.62 KiB
42cfd79 23.75 KiB 880.20 KiB 856.45 KiB
9e0030e 23.75 KiB 893.72 KiB 869.97 KiB
5aa3ce5 23.75 KiB 904.54 KiB 880.79 KiB
f92cfa9 23.75 KiB 855.38 KiB 831.63 KiB
63ac649 23.75 KiB 855.38 KiB 831.63 KiB
efab7d3 23.75 KiB 912.78 KiB 889.03 KiB
d3f650a 23.75 KiB 902.48 KiB 878.73 KiB

Previous results on branch: fixEnergyReporting

Startup times

Revision Plain With Sentry Diff
b84ee62 1221.41 ms 1247.57 ms 26.16 ms

App size

Revision Plain With Sentry Diff
b84ee62 23.75 KiB 912.77 KiB 889.02 KiB

@noahsmartin noahsmartin force-pushed the fixEnergyReporting branch 6 times, most recently from ebd0fca to 26e51b1 Compare July 31, 2025 17:43
@noahsmartin noahsmartin merged commit 81e881f into main Jul 31, 2025
140 of 141 checks passed
@noahsmartin noahsmartin deleted the fixEnergyReporting branch July 31, 2025 19:10
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