This is an archive of the discontinued Mercurial Phabricator instance.

match: optimize matcher when all patterns are of rootfilesin kind
ClosedPublic

Authored by martinvonz on Oct 13 2018, 5:20 AM.

Details

Summary

Internally at Google, we use narrowspecs with only rootfilesin-kind
patterns. Sometimes there are thousands of such patterns
(i.e. thousands of tracked directories). In such cases, it can take
quite long to build and evaluate the resulting matcher.

This patch optimizes matchers that have only patterns of rootfilesin
so it instead of creating a regular expression, it matches the given
file's directory against the set of directories.

In a repo with ~3600 tracked directories, it takes about 1.35 s to
build the matcher and 2.7 s to walk the dirstate before this
patch. After, it takes 0.04 s to create the matcher and 0.87 s to walk
the dirstate.

It may be worthwhile to do similar optimizations for e.g. patterns of
type "kind:", but that's not a priority for us right now.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

martinvonz created this revision.Oct 13 2018, 5:20 AM
This revision was automatically updated to reflect the committed changes.