Personal and Professional blog
by Dan Pilch
Work-in-progress notes on figuring out why
/usr/bin/login
is painfully slow on my MacBook (Apple Silicon, arm64).
A couple of days ago I noticed that terminal sessions using /usr/bin/login
are significantly slower than expected and take 13 minutes to start. This impacts not just Terminal.app and iTerm2, but does not affect vs code
terminal sessionsā¦
Ran the following to trace shell init:
zsh -i -x -c exit
Findings:
oh-my-zsh
, Homebrew init, etc.).zshrc
sections and testing incrementallytime login -f $USER
Still slower than expected. Indicates delay might be deeper than shell config.
Checked logs via:
log show --predicate 'eventMessage contains "login"' --last 5m
Not much of note yet. May need more specific queries.
Looking into /etc/pam.d/login
in case there are any unusual or slow modules.
Troubleshooting this in Slack led to some additional context:
/usr/bin/login
seems to be thrashing CPU at 100%, confirmed via Activity Monitor.login
process.login
, though Terminal is less aggressive on CPU..launchshell.sh
script to bypass login didnāt helpāiTerm2 still invokes login
./etc/resolv.conf
includes 127.0.0.1
, possibly due to Cisco Umbrella, though unchanged.rm -rf ~/Library/Application\ Support/iTerm2/
or move it to reset daemon/config.
dtruss
is Broken on Apple Silicon šTried to trace with:
dtruss login
But on M1/M2 MacBooks:
dtrace: system integrity protection is on, some features will not be available
ksh: dtrace: operation not permitted
Even with SIP disabled, dtruss
often fails or panics the machine.
Currently exploring alternatives like:
opensnoop
fs_usage
instruments
DTrace
scripts (with low expectations)fs_usage
with a ScriptI tried this script to watch /usr/bin/login
as soon as it spawns:
#!/bin/bash
echo "Waiting for /usr/bin/login to start..."
while true; do
pid=$(pgrep -f '^/usr/bin/login' | head -n1)
if [[ -n "$pid" ]]; then
echo "Found login with PID $pid"
echo "Attaching fs_usage..."
sudo fs_usage -w -f filesys -e $pid | gawk '$NF ~ /login/ { print }' | tee loginfs.log
break
fi
sleep 0.5
done
This should help isolate file access patterns right at the moment /usr/bin/login
kicks in.
fs_usage
)/etc/resolv.conf
with 127.0.0.1
)127.0.0.1
entry in resolv.conf
Will keep updating this post as I dig further. If youāve run into this issue or have debugging tips for arm64 macOS, reach out!
tags: