mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
f4c851912d
Often we specify globs in our exclude patterns, e.g: exclude: - **/node_modules - obj* However, these globs get expanded out to *every* file that matches them. This can sometimes be thousands or even tens of thousands of files. We then pass these paths on to the underlying linters and tell them to exclude them all. This causes a lot of overhead and slows down performance. This commit implements a "collapse" function. Given a set of paths, it'll collapse them into the smallest set of parent directories that contain the original set, and that don't contain any extra files. For example, given a directory structure like this: a -- foo.txt -- b -- bar.txt -- baz.txt -- c -- ham.txt -- d -- spam.txt Then the following will happen: >>> collapse(['a/foo.txt', 'a/b/bar.txt', 'a/c/ham.txt', 'a/c/d/spam.txt']) ['a/foo.txt', 'b/bar.txt', 'c'] Since all files under directory 'c' are specified by the original set (both 'c/ham.txt' and 'c/d/spam.txt'), we can collapse it down to just 'c'. However not all files under 'b' are specified (we're missing 'a/b/baz.txt'), so we can't collapse 'b' (and by extension also can't collapse 'a'). If we had included 'a/b/baz.txt': >>> collapse(['a/foo.txt', 'a/b/bar.txt', 'a/b/baz.txt', 'a/c/ham.txt', 'a/c/d/spam.txt']) ['a'] In both cases, the smallest set of paths that contains the original set (and only the original set) is computed. The collapse function has a little bit of overhead but it's not too bad. For example collapsing all files matched by '**/node_modules' takes ~0.015s. Collapsing two full objdirs, takes ~0.6s. But a follow up commit is planned to make sure we stop using 'obj*' to reduce that overhead. Depends on D7738 Differential Revision: https://phabricator.services.mozilla.com/D7739 --HG-- extra : moz-landing-system : lando |
||
---|---|---|
.. | ||
devtools/migrate-l10n | ||
docs | ||
l10n/fluent_migrations | ||
mach | ||
mozboot | ||
mozbuild | ||
mozlint | ||
mozrelease | ||
mozterm | ||
mozversioncontrol | ||
safety | ||
mach_commands.py | ||
moz.build | ||
README |
This directory contains common Python code. The basic rule is that if Python code is cross-module (that's "module" in the Mozilla meaning - as in "module ownership") and is MPL-compatible, it should go here. What should not go here: * Vendored python modules (use third_party/python instead) * Python that is not MPL-compatible (see other-licenses/) * Python that has good reason to remain close to its "owning" (Mozilla) module (e.g. it is only being consumed from there). Historical information can be found at https://bugzilla.mozilla.org/show_bug.cgi?id=775243 https://bugzilla.mozilla.org/show_bug.cgi?id=1346025