You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mingw: avoid O(n*m) rescans when resolving phantom symlinks
On Windows, a symlink must be created as either a "file symlink" or a
"directory symlink", and Git can't always tell which until the target
appears during checkout; until then it's tracked as "phantom" and
rechecked.
Phantom symlinks lived in one global list, fully rescanned by
process_phantom_symlinks() on every mkdir() (and on every symlink
that turns out to point at a directory), making checkout O(n*m) in
outstanding phantom symlinks times directories created. Reported in
#4059 for a git-annex repo where nearly all
symlinks dangle permanently. On a 343-symlink, 37,016-directory
fixture, checkout takes 330s and calls process_phantom_symlink()
12,693,504 times -- about 343 * 37016.
Give process_phantom_symlinks() the path that was just created (a new
directory, or a symlink that turned out to point at one) as its
parameter, and index phantom symlinks in a hashmap keyed by their
(canonicalized, absolute) target path. Waking a path then retries
only the phantom symlinks whose target is exactly that path -- an
O(1) hashmap lookup -- instead of walking the whole list. Same
fixture: 54.9s and 343 calls, one per symlink, no wasted rescans.
Also fixes a pre-existing bug found while testing: wlink and wtarget
are interior pointers into the same allocation as the
phantom_symlink_info struct, not separate allocations, so they must
not be free()'d individually.
Known limitation: if a phantom symlink's target passes through
another symlink as an intermediate component, it is only woken when
that intermediate symlink itself resolves, not when the real
directory it points at is populated later. This is unchanged from
before this patch and expected to be rare in practice.
Signed-off-by: Chris Harris <chris.harris@discordapp.com>
0 commit comments