问题
I am trying to use Zombie in my Node.js project. The project runs in a shared folder on a VirtualBox VM. I am noticing a big drop in performance when Zombie is installed to the shared folder rather than globally.
Suppose I have the following in zombie_test.js:
require("zombie");
If I install zombie globally, the require statement runs in less than a second:
$ sudo npm install zombie -g
...
$ time node zombie_test.js
real 0m0.651s
user 0m0.464s
sys 0m0.116s
If I install the package locally, the require takes 6 seconds.
$ npm install zombie --no-bin-links
...
$ time node zombie_test.js
real 0m5.933s
user 0m0.992s
sys 0m1.424s
This drop in speed does not happen with any other node modules I've tried. It also doesn't happen if I local npm-install to a non-shared directory on the VM.
Does anybody know why this slowdown occurs for zombie, or if I can do something to improve it?
回答1:
Mitchell Hashimoto (the developer of vagrant) put together some test results that show the speeds of different virtual machine file systems. Long story short, native (non shared folders) >>>>>> NFS >> Virtual Box shared folders.
So switching to NFS is a good improvement. However, the latest version of Vagrant added support for Rsync Synced Folders. Using them is a little different from normal shared folders, but the benefit is that in VM file system access is blazing fast. It should be equivalent to the "Native Virtual Box" performance reported in his first blog post.
来源:https://stackoverflow.com/questions/23319680/zombie-js-running-slowly-in-virtualbox-shared-folder