Skip to content

fix: Normalize profiling cpu usage to percent#7798

Open
denrase wants to merge 3 commits intomainfrom
fix/cpu-usage-calc
Open

fix: Normalize profiling cpu usage to percent#7798
denrase wants to merge 3 commits intomainfrom
fix/cpu-usage-calc

Conversation

@denrase
Copy link
Copy Markdown
Collaborator

@denrase denrase commented Apr 13, 2026

📜 Description

Fix SentrySystemWrapper CPU usage calculation by dividing Mach thread cpu_usage by TH_USAGE_SCALE, then normalizing by processor count and converting to 0..100 percent. Updates docs and adds test for the normalization logic.

💡 Motivation and Context

Closes #7456

💚 How did you test it?

Unit Tests

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

Fix SentrySystemWrapper CPU usage calculation by dividing Mach thread cpu_usage by TH_USAGE_SCALE, then normalizing by processor count and converting to 0..100 percent. Updates docs and adds test for the normalization logic.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • Normalize profiling cpu usage to percent by denrase in #7798
  • Detect development builds via provisioning profile entitlement by denrase in #7702

Internal Changes 🔧

Deps

  • Bump actions/upload-pages-artifact from 4.0.0 to 5.0.0 by dependabot in #7789
  • Bump actions/github-script from 8.0.0 to 9.0.0 by dependabot in #7793

🤖 This preview updates automatically when you update the PR.

@denrase denrase marked this pull request as ready for review April 13, 2026 11:36
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.411%. Comparing base (6ea2191) to head (f1a16e3).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #7798       +/-   ##
=============================================
- Coverage   85.416%   85.411%   -0.005%     
=============================================
  Files          487       487               
  Lines        29190     29195        +5     
  Branches     12625     12652       +27     
=============================================
+ Hits         24933     24936        +3     
- Misses        4207      4210        +3     
+ Partials        50        49        -1     
Files with missing lines Coverage Δ
Sources/Sentry/SentrySystemWrapper.mm 67.532% <100.000%> (+1.779%) ⬆️

... and 5 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 6ea2191...f1a16e3. Read the comment docs.

@denrase denrase added the ready-to-merge Use this label to trigger all PR workflows label Apr 14, 2026
@sentry
Copy link
Copy Markdown

sentry bot commented Apr 14, 2026

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.10.0 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1212.11 ms 1250.90 ms 38.79 ms
Size 24.14 KiB 1.13 MiB 1.11 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
21fb20e 1217.43 ms 1230.91 ms 13.48 ms
16b3235 1234.51 ms 1257.84 ms 23.33 ms
fd24b7c 1222.39 ms 1259.67 ms 37.28 ms
d6d7fcf 1192.78 ms 1215.60 ms 22.83 ms
d0b4402 1218.62 ms 1241.80 ms 23.18 ms
db9e223 1193.69 ms 1213.56 ms 19.87 ms
e92ab66 1228.86 ms 1258.43 ms 29.57 ms
bed2eb7 1215.88 ms 1247.14 ms 31.27 ms
06cf46a 1222.49 ms 1261.13 ms 38.64 ms
09a80f2 1214.78 ms 1237.85 ms 23.07 ms

App size

Revision Plain With Sentry Diff
21fb20e 24.14 KiB 1.12 MiB 1.09 MiB
16b3235 24.14 KiB 1.11 MiB 1.09 MiB
fd24b7c 24.14 KiB 1.07 MiB 1.04 MiB
d6d7fcf 24.14 KiB 1.12 MiB 1.10 MiB
d0b4402 24.14 KiB 1.11 MiB 1.08 MiB
db9e223 24.14 KiB 1.06 MiB 1.03 MiB
e92ab66 24.14 KiB 1.10 MiB 1.08 MiB
bed2eb7 24.14 KiB 1.07 MiB 1.04 MiB
06cf46a 24.14 KiB 1.13 MiB 1.10 MiB
09a80f2 24.14 KiB 1.10 MiB 1.08 MiB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: divide cpu_usage by TH_USAGE_SCALE in SentrySystemWrapper.cpuUsage()

1 participant