Sudoless Frequency Metric Retrieval for MacOS (Supports Apple Silicon and Intel CPUs and iGPUs)

Overview

SFMRM ('sifˌmərˌim)

Sudoless Frequency Metric Retrieval for MacOS

Apple Silicon Intel Releases License

This project is designed to retrieve active frequency and residency metrics from your Macs CPU (per-core, per-cluster) and GPU (complex) as accurately and efficiently as possible; accessing the same data as the Powermetrics command line tool, but without requiring sudo or a kernel extension. This is the product of months of reverse engineering, deep analysis, and rigorous testing.

If you would like to support my efforts towards this project, please consider donating to my Cash App.

Installation and Usage

Installation and usage is simple:

  1. Download your architecture specific binary .zip from the latest release.
  2. Unzip the downloaded file (from Finder or Terminal)
  3. Move the binary to your desired location and execute via the Terminal using sfmrm-${ARCH}-client.

To see all available cmd options for your binary, use sfmrm-${ARCH}-client --help.

Capabilities

The following metrics are available on specific architectures.

On Apple Silicon
  • CPU Name, Code Name, and Core Counts
  • CPU Cluster Microarchitecture Names
  • CPU Per-core and Per-cluster Active Frequencies and Active/Idle Residencies
  • CPU (Clusters) and GPU P-State frequency distribution
  • GPU Complex Active Frequencies and Active/Idle Residencies
On Intel
  • CPU Brand Name and Base Frequency
  • CPU Performance Limits, Maximum (P-Limited) Turbo Boost, and Package Clock Multiplier
  • CPU Per-core and Package Active Frequencies and Active/Idle Residencies
  • GPU Performance Limits, Maximum (P-Limited) Dynamic Frequnecy, and Residencies

Example Outputs

The following shows examples on what outputs to expect on specific architectures.

On Apple Silicon

Here is an example using binary sfmrm-arm64-client on an M1 Mac Mini:

*** Sampling: Apple M1 [T8103] (4P+4E+8GPU) ***

**** "Icestorm" Efficiency Cluster Metrics ****

E-Cluster [0]  HW Active Frequency: 1071 MHz
E-Cluster [0]  HW Active Residency: 11.994%
E-Cluster [0]  Idle Frequency:      88.006%

  Core 0:
          Active Frequency: 1129 MHz
          Active Residency: 6.799%
          Idle Residency:   93.201%
  Core 1:
          Active Frequency: 1004 MHz
          Active Residency: 4.364%
          Idle Residency:   95.636%
  Core 2:
          Active Frequency: 990 MHz
          Active Residency: 3.951%
          Idle Residency:   96.049%
  Core 3:
          Active Frequency: 1032 MHz
          Active Residency: 2.023%
          Idle Residency:   97.977%

**** "Firestorm" Performance Cluster Metrics ****

P-Cluster [0]  HW Active Frequency: 1473 MHz
P-Cluster [0]  HW Active Residency: 4.383%
P-Cluster [0]  Idle Frequency:      95.617%

  Core 4:
          Active Frequency: 1487 MHz
          Active Residency: 3.730%
          Idle Residency:   96.270%
  Core 5:
          Active Frequency: 1396 MHz
          Active Residency: 0.739%
          Idle Residency:   99.261%
  Core 6:
          Active Frequency: 600 MHz
          Active Residency: 0.005%
          Idle Residency:   99.995%
  Core 7:
          Active Frequency: 600 MHz
          Active Residency: 0.005%
          Idle Residency:   99.995%

**** Integrated Graphics Metrics ****

GPU  Active Frequency: 712 MHz
GPU  Active Residency: 1.581%
GPU  Idle Frequency:   98.419%
On Intel

Here is an example using binary sfmrm-x86_64-client on an Intel® Core™ i7-4578U 13" MacBook Pro:

*** Sampling: Intel(R) Core(TM) i7-4578U CPU @ 3.00GHz ***

**** Package Metrics ****

Package  Performance Limiters: MAX_TURBO_LIMIT
Package  Maximum Turbo Boost:  3500 MHz

Package  Clock Multiplier: x21.8
Package  Active Frequency: 2184 MHz
Package  Active Residency: 55.83% 
Package  Idle Residency:   44.17% 

  Core 0:
          Active Frequency: 2207 MHz
          Active Residency: 66.34% 
          Idle Residency:   33.66% 
  Core 1:
          Active Frequency: 2132 MHz
          Active Residency: 47.00% 
          Idle Residency:   53.00% 
  Core 2:
          Active Frequency: 2992 MHz
          Active Residency: 65.00% 
          Idle Residency:   35.00% 
  Core 3:
          Active Frequency: 2412 MHz
          Active Residency: 45.00% 
          Idle Residency:   55.00% 

**** Integrated Graphics Metrics ****

iGPU  Performance Limiters:      VR_ICCMAX
iGPU  Limited Dynamic Frequency: 1200 MHz

iGPU  Active Residency: 4.00%
iGPU  Idle Frequency:   96.00%

Bugs and Issues

Identified
  • Outputs on M1 Pro/Max/Ultra may not work as expected (IOReport entries are unknown so support is unofficial)

If any other bugs or issues are identified or you want your system supported, please let me know in the issues section.

Comments
  • metric power doesn't work in my mac.

    metric power doesn't work in my mac.

    Describe the bug The app is terminated with NSRangeException. In my Xcode, it seems like 'key error'. There's no 'Energy Counters' in pwrsamples.

    Operating System (please complete the following information):

    • Name: Monterey
    • Version 12.4

    Device (please complete the following information):

    • Model: 2021 MacBook Pro 16 / MacBookPro18,1
    • CPU: Apple M1 Pro
    bug trying to fix 
    opened by op06072 25
  • [Issue] In v0.3, there's 'NSRangeException'

    [Issue] In v0.3, there's 'NSRangeException'

    Describe the bug When printing about PCPU1's info, there's 'NSRangeException'

    Operating System (please complete the following information):

    • Name: Ventura
    • Version 13.0

    Device (please complete the following information):

    • Model: 2021 MacBook Pro / MacBookPro18,1
    • CPU: Apple M1 Pro

    Additional context 2022-08-22 10:04:26.763 socpwrbud 2[77096:665102] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndexedSubscript:]: index 2 beyond bounds [0 .. 1]' *** First throw call stack: ( 0 CoreFoundation 0x00000001b23bbe08 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x00000001b1f0aea8 objc_exception_throw + 60 2 CoreFoundation 0x00000001b24a03b4 -[__NSCFString characterAtIndex:].cold.1 + 0 3 CoreFoundation 0x00000001b232dc20 -[__NSCFString hasSuffix:] + 0 4 socpwrbud 2 0x0000000104dca878 textOutput + 1232 5 socpwrbud 2 0x0000000104dcf888 main + 6264 6 dyld 0x00000001b1f3be38 start + 2520 ) libc++abi: terminating with uncaught exception of type NSException [1] 77096 abort ./socpwrbud\ 2

    bug 
    opened by op06072 8
  • [Issue] I find some bugs in logic

    [Issue] I find some bugs in logic

    Describe the bug

    1. In static data, channels names of M1 Ultra are not correct. So this doesn't work in ultra.
    2. There's error in cluster_core_counts of static data. In this logic, we can get [2, 4, 4] but we need [2, 2, 4, 4, 4, 4].

    Operating System (please complete the following information):

    • Name: Ventura
    • Version 13.0

    Device (please complete the following information):

    • Model: 2021 Mac Studio
    • CPU: Apple M1 Ultra

    Additional context Thank you for allowing me to use this project. Finally my new asitop(a.k.a neoasitop) project is complete! https://github.com/op06072/NeoAsitop

    bug trying to fix 
    opened by op06072 3
  • [Issue] printing format string is still printed when I use option '-po'.

    [Issue] printing format string is still printed when I use option '-po'.

    Describe the bug when I save the output plist file with '-po' option, The program's output is still printed with <dict> tag.

    Operating System (please complete the following information):

    • Name: Monterey
    • Version 12.5

    Device (please complete the following information):

    • Model: 2021 MacBook Pro / MacBookPro18,1
    • CPU: Apple M1 Pro
    bug fixed and upcoming 
    opened by op06072 3
  • ERROR:

    ERROR: "invalid output from sysctl" & Compilation Command

    Hi! when I run the precompiled binary osx-cpufreq on apple M1 Big Sur 11.4, it generates the error of "invalid output from sysctl". Personally think that below the two lines are the source of the issue (I also posted the same issue in repository of M1-siliconpower). Could you help here?

    int             e_core_count        = get_sysctl_int(SYSCTL_ECPU);
    int             p_core_count        = get_sysctl_int(SYSCTL_PCPU);
    

    Could you also post the compilation command (clang ...)? Many thanks!

    opened by jingchen95 1
  • [Issue] Is there any way to prevent memory leak caused by using IOReport functions?

    [Issue] Is there any way to prevent memory leak caused by using IOReport functions?

    Describe the bug In my project and also your project, there's quite a large memory leak.

    Operating System (please complete the following information):

    • Name: Ventura and Monterey
    • Version 13.0 and 12.6

    Device (please complete the following information):

    • Model: 2021 Macbook Pro and Mac Studio and 2020 Macbook Air
    • CPU: Apple M1 and M1 Pro and M1 Ultra

    Additional context When we use the 'IOReportCreateSamples(Delta)', these functions causes memory leak. In my case, about 9.6GiB of memory leak occured after two days of use.

    bug investigating 
    opened by op06072 1
Releases(v0.3.1)
  • v0.3.1(Oct 21, 2022)

  • v0.3(Aug 19, 2022)

    Release Notes

    This minor is a bit light on updates, but contains a decent bug fix plus some new metrics; as well as source code for the diagnostic tool.

    Changelog

    Features

    • Added metric for supposed CPU cycles spent during sample
    • Added metric for Idle residencies (just for niceness)

    Fixes

    • Fixed issue #3 (not all stdout redirected when using opt -o)

    Misc

    • Added source and binary for diagnostic tool
    Source code(tar.gz)
    Source code(zip)
    iorepdump.zip(6.31 KB)
    socpwrbud-v0.3.zip(27.05 KB)
  • v0.2(Aug 7, 2022)

    Release Notes

    This minor contains decent improves, bug fixes, and a lot of new features!

    Changelog

    Features

    • Added arg -p to allow outputting metrics formatted as plist
    • Added arg -o to allow setting a file for stdout
    • Added metric for time (in milliseconds) spent in each unit's Dvfm state
    • Added per-core Dvfm state statistics for distribution and time
    • Added Instructions retired and per-clock metrics for CPU clusters

    Fixes

    • Fixed frequencies and residencies returning as negative when unit in a inactive state

    Improvements

    • Renamed pstates metrics to dvfm to follow more of an architecture appropriate style of terminology
    • Improved output formatting by removing decimal places on values that have no remainders
    Source code(tar.gz)
    Source code(zip)
    socpwrbud-v0.2.zip(26.37 KB)
  • v0.1.2(Jul 29, 2022)

    Release Notes

    This patch contains improvements to portability, metrics management, and includes a fix for a juicy memory leak issue.

    Changelog

    Fixes

    • Fixed a memory leak that resulted in the tool consuming ~1.5 MB of memory every sample

    Improvements

    • Now pulling Silicon IDs/Code names from the IORegistry
    • Now pulling CPU micro architectures from the IORegistry
    • Improved managing metrics for visible units by adding command line arg -a
    Source code(tar.gz)
    Source code(zip)
    mxsocpwrbud-v0.1.2.zip(23.36 KB)
  • v0.1.1(Jul 20, 2022)

    Release Notes

    This patch brings support for Apple M1 Pro/Max/Ultra Silicon with increased portability and chance of supporting new silicon as well.

    Changelog

    Features and Fixes

    • ADDED Apple M1 Pro/max/Ultra support (closes issue #2)
    • FIXED Unit hiding not working for ECPU due to unfixed loop code

    Improvements

    • Code reduction and increased portability
    • Codesigned release
    Source code(tar.gz)
    Source code(zip)
    mxsocpwrbud-v0.1.1.zip(22.26 KB)
  • v0.1.0(Jul 2, 2022)

Owner
BitesPotatoBacks
Knowledge is power!
BitesPotatoBacks
A Cocoa NSFormatter subclass to convert dates to and from ISO-8601-formatted strings. Supports calendar, week, and ordinal formats.

ISO 8601: The only date format worth using Obligatory relevant xkcd: How to use this code in your program Add the source files to your project. Parsin

Peter Hosey 601 Sep 4, 2022
A minimal hexadecimal clock for the Apple TV.

Hex Color Clock A simple, minimal hexadecimal clock for the Apple TV. Download it on the App Store! Dependencies Fastlane is used to manage the build

Colin Drake 17 Jul 19, 2022
SwiftMoment - A time and calendar manipulation library for iOS 9+, macOS 10.11+, tvOS 9+, watchOS 2+ written in Swift 4.

SwiftMoment This framework is inspired by Moment.js. Its objectives are the following: Simplify the manipulation and readability of date and interval

Adrian Kosmaczewski 1.6k Oct 4, 2022
Timekeeper is an easy-to-use time measurement library written in Swift, with support for iOS, tvOS, watchOS and macOS.

Timekeeper is an easy-to-use time measurement library written in Swift, with support for iOS, tvOS, watchOS and macOS. Installation Timekee

Andreas Pfurtscheller 1 Oct 18, 2021
MinimalClock: a MacOS screen saver

MinimalClock: a MacOS screen saver

Mattia Rossini 88 Nov 25, 2022
A TimeZonePicker UIViewController similar to the iOS Settings app. Search and select from a range of cities and countries to find your most suitable time zone.

TimeZonePicker A TimeZonePicker UIViewController similar to the iOS Settings app. Search and select from a range of cities and countries to find your

Gligor Kotushevski 125 Nov 6, 2022
A basic countdown app that allows the user to create, edit, and delete events. Each event contains a live countdown timer to a specified date and time.

Event Countdown App (iOS) Created by Lucas Ausberger About This Project Created: January 4, 2021 Last Updated: January 8, 2021 Current Verison: 1.1.1

Lucas Ausberger 1 Jan 8, 2022
Create your own faces for watchOS. Customize the watch hands, layout, colors, and images. Edit faces on your phone and switch them on the watch.

AppleWatchFaces Design your own watch faces for the apple watch. They are not real watch faces, but a watchOS app running on the watch that tells you

Mike Hill 395 Oct 20, 2022
Time is a Swift package that makes dealing with calendar values a natural and straight-forward process.

Time Time is a Swift package that makes dealing with calendar values a natural and straight-forward process. Working with calendars can be extremely c

Dave DeLong 2k Oct 31, 2022
📆 Breeze through Date, DateComponents, and TimeInterval with Swift!

Datez ?? Breeze through Date, DateComponents, and TimeInterval Highlights Two Custom Structs Only (value types FTW!): DateView: An Date associated wit

Kitz 264 Oct 29, 2022
NVDate is an extension of NSDate class (Swift4), created to make date and time manipulation easier.

NVDate is an extension of NSDate class (Swift4), created to make date and time manipulation easier. NVDate is testable and robust, we wrote intensive test to make sure everything is safe.

Noval Agung Prayogo 177 Oct 5, 2022
SwiftDate 🐔 Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.

Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift. What's This? SwiftDate is the definitive toolchain to ma

Daniele Margutti 7.1k Nov 18, 2022
NTP library for Swift and Objective-C. Get the true time impervious to device clock changes.

TrueTime for Swift Make sure to check out our counterpart too: TrueTime, an NTP library for Android. NTP client for Swift. Calculate the time "now" im

Instacart 525 Oct 27, 2022
Dates and times made easy in iOS

DateTools DateTools was written to streamline date and time handling in iOS. Classes and concepts from other languages served as an inspiration for Da

Matthew York 7.2k Nov 9, 2022
A "time ago", "time since", "relative date", or "fuzzy date" category for NSDate and iOS, Objective-C, Cocoa Touch, iPhone, iPad

Migration 2014.04.12 NSDate+TimeAgo has merged with DateTools. DateTools is the parent project and Matthew York is the project head. This project is n

Kevin Lawler 1.8k Oct 27, 2022
A Swift micro library for generating Sunrise and Sunset times.

Solar A Swift helper for generating Sunrise and Sunset times. Solar performs its calculations locally using an algorithm from the United States Naval

Chris Howell 489 Nov 16, 2022
Custom Time Picker ViewController with Selection of start and end times in Swift 🔶

LFTimePicker Custom Time Picker ViewController with Selection of start and end times in Swift ?? . Based on Adey Salyard's design @ Dribbble One to tw

Awesome Labs 65 Nov 11, 2022
SwiftUI library to display a clock. You can move the arms to change the time, change the style of the clock and customise some configurations.

SwiftClockUI Clock UI for SwiftUI This library has been tested ✅ ?? macOS Catalina 10.15.3 ✅ ?? macOS Big Sur 11.6 ✅ ?? iOS 13 ✅ ?? iOS 14 ✅ ?? iOS 15

Renaud Jenny 233 Oct 22, 2022
A customizable date picker for watchOS and SwiftUI.

Watch Date Picker A customizable date picker for watchOS and SwiftUI. Installation .package(url: "https://github.com/freyaariel/watch-date-picker.git"

Freya Ariel 27 Nov 19, 2022