Macos login from terminal (Terminal/iTerm) takes long time with high CPU
After more digging, it turned out that the slowness of login was caused by lsof.
login calls lsof at some point which takes very long time to finish.
After some trials and errors, I had to reset max file descriptors limit to default to solve the issue.
I don't know the exact relationship between lsof and max file descriptors limit but it turned out that large max file limits slow down lsof dramatically.