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

Fix: Avoid potential delay in calc of RAM (darwin) #243

Merged

Conversation

aftaylor2
Copy link
Member

The system_profiler command used to determine the total memory on darwin systems performs an "Activation Lock" check. This can produce a delay in returning total memory. I began experiencing delays of around 10 seconds.

Switching from system_profiler to sysctl to calculate total memory bypasses the "Activation Lock" check / timeout scenario.

Results of "time" command using system_profiler:

system_profiler SPHardwareDataType 0.17s user 0.23s system 3% cpu 10.165 total grep -a "Memory:" 0.00s user 0.00s system 0% cpu 10.164 total awk '{print $2 $3}' 0.00s user 0.00s system 0% cpu 10.163 total

Results of "time" command using sysctl:

sysctl -n hw.memsize 0.00s user 0.00s system 83% cpu 0.004 total awk '{print $0/1024/1024/1024 " GB"}' 0.00s user 0.00s system 86% cpu 0.004 total

The system_profiler command used to determine the total memory on darwin
systems performs an "Activation Lock" check. This can produce a delay in
returning total memory. I began experiencing delays of around 10 seconds.

Switching from system_profiler to sysctl to calculate total memory
bypasses the "Activation Lock" check / timeout scenario.

Results of "time" command using system_profiler:
system_profiler SPHardwareDataType  0.17s user 0.23s system 3% cpu 10.165 total
grep -a "Memory:"  0.00s user 0.00s system 0% cpu 10.164 total
awk '{print $2 $3}'  0.00s user 0.00s system 0% cpu 10.163 total

Results of "time" command using sysctl:
sysctl -n hw.memsize  0.00s user 0.00s system 83% cpu 0.004 total
awk '{print $0/1024/1024/1024 " GB"}'  0.00s user 0.00s system 86% cpu 0.004 total
@aftaylor2
Copy link
Member Author

I forgot to include the associated error message when experiencing the timeout:

2023-12-15 10:36:11.989 system_profiler[12578:260685] Timed out waiting for the Activation Lock Capable check

@ethancedwards8
Copy link
Member

Awesome, I much prefer this solution anyways. Thank you for the find and the contribution!

@ethancedwards8 ethancedwards8 merged commit 3f2466a into dracula:master Dec 17, 2023
1 check passed
@aftaylor2 aftaylor2 deleted the fix_ram_info_darwin_total_mem branch December 18, 2023 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants