Bug 205938 - Start-up for 64-bit programs on Mac OS X is slow
Summary: Start-up for 64-bit programs on Mac OS X is slow
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.5.0
Platform: Unlisted Binaries macOS
: NOR normal
Target Milestone: blocking3.5.1
Assignee: Julian Seward
Depends on:
Reported: 2009-09-02 01:00 UTC by Nicholas Nethercote
Modified: 2010-01-18 00:50 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Note You need to log in before you can comment on or make changes to this bug.
Description Nicholas Nethercote 2009-09-02 01:00:48 UTC
Valgrind's 64-bit Darwin support is not very good at the moment.  In particular, both 32-bit and 64-bit Darwin ports rely on mmapping large chunks of the address space to prevent them being used by dyld (I think?)  This works ok on 32-bits, but on 64-bits the mmaps are so large that they take a long time.  Eg. on my MacBook Pro it takes about 4 seconds to do this.

Given how much people complain about Valgrind's slowness in general, it's likely to cause rioting in the streets as people transition to Mac OS 10.6, which uses 64-bit executables by default.  It also makes the regression test suite very painful to run, because it has over 400 short-running tests.

The Linux version of Valgrind doesn't require these start-up mmaps.  Here's Greg Parker's explanation of why the Darwin version has them:

> The memory maps are there to make sure that Valgrind's copies of libc
> and dyld load in a non-default location, so that the inferior's own libc
> and dyld do load in the default locations. (The kernel performs the work
> of loading several things as described by the executable's load
> commands, including the executable itself, dyld, the main thread's
> stack, and the page-zero segment.)  There might be a way to fine-tune it
> so the maps are smaller but still do the job.
> The post-launch mmap behavior can be cleaned up - looks like we don't
> unmap as much as we should - which would improve post-launch
> performance.
> Hmm, there might be an extra-clever way to give Valgrind a custom
> MH_DYLINKER that performs the "bootloader" work of loading dyld in an
> acceptable place and then unloading itself. Then no mmaps would be
> needed. I'll have to think about that one.
Comment 1 Greg Parker 2009-09-16 21:17:46 UTC
The 10.6 patch in bug 205241 has the munmap-more change, which should help some. The substitute MH_DYLINKER still looks like a feasible approach despite a few sticking points.
Comment 2 Nicholas Nethercote 2009-09-17 00:23:53 UTC
I've marked this as blocking 3.5.1.  We probably won't be able to fix it fully for 3.5.1, but we should at least measure the changes mentioned in comment 1 and see if we can do anything else easily.