Hi, Mike.
This sounds great!
On Tue, Nov 12, 2013 at 3:00 PM, Mike Shal <
mar...@gmail.com> wrote:
> Hi all,
>
> I'm considering removing the use of FUSE on OSX and bringing back the
> DYLD_INSERT_LIBRARIES approach. When Anatol suggested it a few months ago I
> gave it a whirl but was stymied by a few test cases that indicated
> performance would be worse than fuse. This consisted of a simple empty .c
> file compilation:
>
> $ time gcc -c ok.c
> real 0m0.026s
> user 0m0.012s
> sys 0m0.011s
>
> $ time DYLD_FORCE_FLAT_NAMESPACE=1 gcc -c ok.c
> real 0m0.049s
> user 0m0.036s
> sys 0m0.010s
>
> However, for some more real-world use-cases, it seems this slow-down is
> additive rather than multiplicative. Eg I have one link job that takes
> 5.436s, and with DYLD_FORCE_FLAT_NAMESPACE it goes up to 5.472s. In
> comparison, running in a chrooted fuse environment is 9.669s, so the shared
> library approach clearly wins.
I am a bit surprised. I would expect that DYDL way will be faster and
definitely more scalable. FUSE has to copy data to kernel and then
back to userspace, while DYDL does not do it. Another issue with fuse
on osx is that it has limited scalability. Fuse4X has
one-request-per-filesystem limitation, while OSXFUSE even worse - one
request for all filesystems. So running build with many threads should
show better performance with DYDL.
> I started to implement the old ldpreload approach (for OSX only), and the
> branch is on github. At the moment I'm looking for some feedback to know if
> it is worth finishing the branch and merging it in, or if we should still
> stay the course with fuse. If you use tup on OSX, please copy your project
> into a separate area to try it out since not all of the test cases are
> passing yet. I'm curious to know:
>
> 1) How does performance compare vs the latest tup master using fuse?
> 2) Is there anything broken (aside from the caveats below)?
>
> Caveats:
>
> 1) No variants yet
> 2) No run-scripts yet
> 3) Some symlink tests and wrong target tests are still broken, so it is not
> suited for actual development yet.
>
> Fixing the above will take a while, so before I put in the effort I want to
> know if it will be worth it :)
>
> The advantages should be the performance, and the fact that we don't need a
> chroot environment to avoid the annoying paths issue with fuse.
Another difference is that fuse implementations on osx seriously
lagging and have many "issues". Here are few examples:
- osx vfs kernel layer is derived from freebsd. Its kernel API does
not allow to distinguish operation for different file descriptors. So
when several threads open the same file and read it then kernel does
not know what exactly fd is used. From other side fuse userspace API
follows Linux kernel API that passes valid filedescriptor to vfs
functions. See fuse_file_info->fh field in libfuse API.
- fuse on osx does not have ioctl() implementation. fuse
implementation on linux has it (almost) for free, while osx kernel
requires a lot plumbing code.
> The
> disadvantage is figuring out how to support variants and such with it. Based
> on what Anatol said, I believe we don't have as big of a concern with
> binaries on OSX statically linking libc, so we should be safe to use the
> approach.
I confirm it. Here is more info
http://stackoverflow.com/questions/5259249/creating-static-mac-os-x-c-build
Basically Apple developers decide to provide libSystem as an API and
hide kernel details. This allows Apple developers do not worry about
syscall compatibility issues. There is probably possible to write an
assembler program that uses syscalls directly to manipulate files but
I doubt anyone does it in the real life.