【问题标题】:Python slow after mounting with sshfs使用 sshfs 挂载后 Python 速度变慢
【发布时间】:2015-04-02 13:46:55
【问题描述】:

我发现使用 sshfs 挂载外部驱动器后,我的 python 启动速度非常慢。当我再次卸载驱动器时,python 启动速度很快。

我没有提及在我的 .bashrc 或 .pythonrc 中安装的驱动器。为什么安装驱动器后 python 启动如此缓慢,我该怎么做才能避免呢?

我在 Mac 上运行 Mavericks,并从 Macports 运行 python。

【问题讨论】:

  • 我会使用 dtruss 这样的工具来检查 python 停止的系统调用
  • 我怀疑像stat() 这样的东西......
  • 我尝试使用 dtruss,但我不确定我是否理解输出。它给出了一个长线程,输出如下: stat64("/AppleInternal\0", 0x7FFF5AECB768, 0x0) = -1 Err#2 audit_session_self(0x7FFF5AECB620, 0x7FFF5AECB458, 0x4) = 4099 0 geteuid(0x7FFF5AECB620, 0x7FFF5AECB458, 0x0) getegid(0x7FFF5AECB620, 0x7FFF5AECB458, 0x0) = 20 0 getaudit_addr(0x7FFF5AECB6F8, 0x30, 0x0) = 0 0 csops(0xFD1A, 0x7, 0x7FFF5AECB2E0) = -1 Err#22
  • 您可能应该将它与时间测量选项(-d 和/或-e)一起使用,然后检查 python 在哪个启动点冻结一段时间。

标签: python sshfs


【解决方案1】:

这可能是因为您的PYTHONPATH 包含已安装的路径。所以像import os 这样的每个导入都会在PYTHONPATH 中搜索os。 要通过 sshfs 加快这些导入,您可能需要将 -o negative_timeout=1000 添加到 sshfs。它告诉 sshfs 的缓存在 1000 秒内记住它在那里没有找到那些包。

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

警告:您可能会在 1000 秒内通过 sshfs 看到新文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多