0

I have found that my python starts up very slow after I mount an external drive using sshfs. When I unmount the drive again the the python startup is fast.

I make no mention of the mounted drive in my .bashrc or .pythonrc. Why is the python startup so slow with a mounted drive and what can I do to avoid it?

I am running Mavericks on a mac and python from Macports.

acbowz
  • 21
  • 2
  • I would use a tool like [dtruss](https://opensourcehacker.com/2011/12/02/osx-strace-equivalent-dtruss-seeing-inside-applications-what-they-do-and-why-they-hang/) to check on what syscalls python stops – user3159253 Apr 02 '15 at 13:53
  • I'd suspect something like `stat()` or so... – user3159253 Apr 02 '15 at 13:53
  • I tried using dtruss but I am not sure I understand the output. It gives a long thread with output like: stat64("/AppleInternal\0", 0x7FFF5AECB768, 0x0) = -1 Err#2 audit_session_self(0x7FFF5AECB620, 0x7FFF5AECB458, 0x4) = 4099 0 geteuid(0x7FFF5AECB620, 0x7FFF5AECB458, 0x0) = 0 0 getegid(0x7FFF5AECB620, 0x7FFF5AECB458, 0x0) = 20 0 getaudit_addr(0x7FFF5AECB6F8, 0x30, 0x0) = 0 0 csops(0xFD1A, 0x7, 0x7FFF5AECB2E0) = -1 Err#22 – acbowz Apr 02 '15 at 14:07
  • Likely you should use it with time measuring options (`-d` and/or `-e`) and then check at which point of startup python freezes for a while. – user3159253 Apr 02 '15 at 16:07

1 Answers1

0

This is probably because your PYTHONPATH includes the mounted path. So every import like import os searches for os in that PYTHONPATH. To speed up these imports over sshfs, you probably want to add -o negative_timeout=1000 to sshfs. It tells sshfs's cache to remember for 1000 secs that it didn't find those packages there.

sshfs -o negative_timeout=1000  remotehost:/dir /dir

Caveat: you may mot see new files over sshfs for 1000 secs.

Yariv
  • 381
  • 3
  • 11