From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>,
Andy Shevchenko <andy@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] lib: remove leading spaces before tabs
Date: Thu, 10 Jun 2021 12:10:11 +0300 [thread overview]
Message-ID: <YMHW80wUyFpW6Utf@smile.fi.intel.com> (raw)
In-Reply-To: <7e0f67a63b7093f4d20e0c0ccb076d9244e26a9a.camel@perches.com>
On Wed, Jun 09, 2021 at 02:44:54PM -0700, Joe Perches wrote:
> On Wed, 2021-06-09 at 13:30 +0300, Andy Shevchenko wrote:
> > On Wed, Jun 9, 2021 at 9:21 AM Leizhen (ThunderTown)
> > <thunder.leizhen@huawei.com> wrote:
> > > On 2021/6/9 13:15, Leizhen (ThunderTown) wrote:
> > > > On 2021/6/9 0:03, Joe Perches wrote:
> > > > > On Tue, 2021-06-08 at 17:00 +0800, Leizhen (ThunderTown) wrote:
> > > > > > On 2021/6/8 16:44, Andy Shevchenko wrote:
> > > > > > > On Tue, Jun 8, 2021 at 10:14 AM Zhen Lei <thunder.leizhen@huawei.com> wrote:
> > > > > > > >
> > > > > > > > 1) Run the following command to find and remove the leading spaces before
> > > > > > > > tabs:
> > > > > > > > find lib/ -type f | xargs sed -r -i 's/^[ ]+\t/\t/'
> > > > > > >
> > > > > > > Hint for the future, try to use what Git provides, for example `git
> > > > > > > ls-files -- lib/`.
> > > > > >
> > > > > > Okay, thanks. I learned a new trick.
> >
> > > > > For instance:
> > > > >
> > > > > $ git diff --stat lib
> > > > > $ git ls-files lib/ | \
> > > > > xargs ./scripts/checkpatch.pl --types=SPACE_BEFORE_TAB --fix-inplace
> > >
> > > I just tried it. It's too slow.
> >
> > If checkpath accepts infinite positional arguments, then proper way of
> > use (that's how I do with simple perl regexps) is to
> >
> > scripts/checkpatch.pl --types=SPACE_BEFORE_TAB --fix-inplace -- $(git ls-files lib/)
>
> That won't always work:
>
> $ git ls-files | xargs | wc -c
> 2716737
>
> Nothing accepts infinite positional arguments.
> You are always limited by the maximum length of a command line
>
> $ getconf ARG_MAX
> 2097152
>
> xargs has:
>
> $ xargs --show-limits
> Your environment variables take up 3517 bytes
> POSIX upper limit on argument length (this system): 2091587
> POSIX smallest allowable upper limit on argument length (all systems): 4096
> Maximum length of command we could actually use: 2088070
> Size of command buffer we are actually using: 131072
> Maximum parallelism (--max-procs must be no greater): 2147483647
If you care about parallelism, the checkpatch should be doing it itself.
Currently it's one perl interpreter with a single queue vs. zillions of perl
invocations (with all downsides of this). And I'm not sure which one is a
winning.
And yes, I'm aware of why xargs is ever exists (including handling of the
special file names).
> > Seems like we have a shell lesson :-)
>
> Maybe so.
>
> Using xargs allows use of -P to invoke parallelism.
> Or you could just use gnu parallel instead of xargs.
>
> Using './scripts/checkpatch.pl -- $(git ls-files <path>)' will only
> allow a single process to be invoked for the files to be scanned.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2021-06-10 9:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-08 7:14 [PATCH 1/1] lib: remove leading spaces before tabs Zhen Lei
2021-06-08 8:44 ` Andy Shevchenko
2021-06-08 9:00 ` Leizhen (ThunderTown)
2021-06-08 16:03 ` Joe Perches
2021-06-09 5:15 ` Leizhen (ThunderTown)
2021-06-09 5:52 ` Joe Perches
2021-06-09 6:21 ` Leizhen (ThunderTown)
2021-06-09 6:35 ` Joe Perches
2021-06-09 10:30 ` Andy Shevchenko
2021-06-09 13:31 ` Leizhen (ThunderTown)
2021-06-09 21:44 ` Joe Perches
2021-06-10 9:10 ` Andy Shevchenko [this message]
2021-06-10 12:05 ` Joe Perches
2021-06-10 12:26 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YMHW80wUyFpW6Utf@smile.fi.intel.com \
--to=andy.shevchenko@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andy@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=thunder.leizhen@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).