Re: [PATCH 8/9] perl: lazily load some common Git.pm setup code
- From
- Eric Wong <e@80x24.org>
- Date
- May 12, 2021, 18:05 UTC
- Message-ID
- <20210512180517.GA11354@dcvr>
- In-Reply-To
- <patch-8.9-2312346f71-20210512T132955Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 8 quoted lines
> @@ -408,10 +404,12 @@ sub command_bidi_pipe {
> my $cwd_save = undef;
> if ($self) {
> shift;
> - $cwd_save = cwd();
> + require Cwd;
> + $cwd_save = Cwd::cwd();
> _setup_git_cmd_env($self);(This also applies to 7/9)
Cwd::cwd() execs /bin/pwd (at least on Perl 5.28.1 in Debian 10x). There should be a benefit from using Cwd::getcwd() here, instead.
strace -f -e execve perl -MCwd -E 'Cwd::cwd()
...confirms the execve is happening.
getcwd() takes 25ms vs 27ms of cwd() for me using the "schedutil" CPU governor under Linux:
time perl -MCwd -E 'Cwd::getcwd()' time perl -MCwd -E 'Cwd::cwd()'