git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Gregory Anders" <greg@gpanders.com>,
	"Đoàn Trần Công Danh" <congdanhqx@gmail.com>,
	"Jeff King" <peff@peff.net>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Eric Wong" <e@80x24.org>,
	"Felipe Contreras" <felipe.contreras@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v5 00/13] send-email: various optimizations to speed up by >2x
Date: Fri, 28 May 2021 11:23:39 +0200	[thread overview]
Message-ID: <cover-00.13-00000000000-20210528T092228Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-00.13-00000000000-20210524T074932Z-avarab@gmail.com>

Hopefully the final iteration. Updates a commit message to explain why
I moved away from File::Spec::Functions, rebases on master, and
explains and deals with the "undef in config" issue Jeff King noted.

Ævar Arnfjörð Bjarmason (13):
  send-email tests: support GIT_TEST_PERL_FATAL_WARNINGS=true
  send-email tests: test for boolean variables without a value
  send-email: remove non-working support for "sendemail.smtpssl"
  send-email: refactor sendemail.smtpencryption config parsing
  send-email: copy "config_regxp" into git-send-email.perl
  send-email: lazily load config for a big speedup
  send-email: lazily shell out to "git var"
  send-email: use function syntax instead of barewords
  send-email: get rid of indirect object syntax
  send-email: lazily load modules for a big speedup
  perl: lazily load some common Git.pm setup code
  send-email: move trivial config handling to Perl
  perl: nano-optimize by replacing Cwd::cwd() with Cwd::getcwd()

 Documentation/config/sendemail.txt |   3 -
 git-send-email.perl                | 174 +++++++++++++++++++----------
 perl/Git.pm                        |  32 +++---
 t/t9001-send-email.sh              |  29 +++++
 4 files changed, 159 insertions(+), 79 deletions(-)

Range-diff against v4:
 1:  7140847367c =  1:  81025b48f1c send-email tests: support GIT_TEST_PERL_FATAL_WARNINGS=true
 2:  d27f3b48f85 =  2:  16277bd1082 send-email tests: test for boolean variables without a value
 3:  a7a21b75f2e =  3:  e3e3e6415d2 send-email: remove non-working support for "sendemail.smtpssl"
 4:  7356a528589 =  4:  961ca4c2b2a send-email: refactor sendemail.smtpencryption config parsing
 5:  cce0f89143b =  5:  f2bd12728a1 send-email: copy "config_regxp" into git-send-email.perl
 6:  8afe8661761 =  6:  4cf70c6f97e send-email: lazily load config for a big speedup
 7:  491eefde6a2 =  7:  bd0d9535718 send-email: lazily shell out to "git var"
 8:  860156013f8 =  8:  f1a879a8ae9 send-email: use function syntax instead of barewords
 9:  dd24f1249f5 =  9:  881b1093409 send-email: get rid of indirect object syntax
10:  61e3e3c93c5 ! 10:  9f21bc6e6f2 send-email: lazily load modules for a big speedup
    @@ Commit message
         under NO_GETTEXT=[|Y], respectively. Now it's 52/37. It now takes ~15s
         to run t9001-send-email.sh, down from ~20s.
     
    +    Changing File::Spec::Functions::{catdir,catfile} to invoking class
    +    methods on File::Spec itself is idiomatic. See [1] for a more
    +    elaborate explanation, the resulting code behaves the same way, just
    +    without the now-pointless function wrapper.
    +
    +    1. http://lore.kernel.org/git/8735u8mmj9.fsf@evledraar.gmail.com
    +
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
      ## git-send-email.perl ##
    @@ git-send-email.perl: sub maildomain_mta {
      		if (defined $smtp) {
      			my $domain = $smtp->domain;
     @@ git-send-email.perl: sub validate_patch {
    - 	my ($fn, $xfer_encoding) = @_;
      
      	if ($repo) {
    --		my $validate_hook = catfile($repo->hooks_path(),
    + 		my $hooks_path = $repo->command_oneline('rev-parse', '--git-path', 'hooks');
    +-		my $validate_hook = catfile($hooks_path,
     +		require File::Spec;
    -+		my $validate_hook = File::Spec->catfile($repo->hooks_path(),
    ++		my $validate_hook = File::Spec->catfile($hooks_path,
      					    'sendemail-validate');
      		my $hook_error;
      		if (-x $validate_hook) {
11:  ada34374286 ! 11:  66f68e38c16 perl: lazily load some common Git.pm setup code
    @@ perl/Git.pm: sub get_tz_offset {
      	my $sign = qw( + + - )[ $gm <=> $t ];
      	return sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]);
      }
    -@@ perl/Git.pm: sub hooks_path {
    - 	my ($self) = @_;
    - 
    - 	my $dir = $self->command_oneline('rev-parse', '--git-path', 'hooks');
    --	my $abs = abs_path($dir);
    -+	require Cwd;
    -+	my $abs = Cwd::abs_path($dir);
    - 	return $abs;
    - }
    - 
     @@ perl/Git.pm: sub _temp_cache {
      		my $n = $name;
      		$n =~ s/\W/_/g; # no strange chars
12:  3818000bfba ! 12:  f605b5ae49f send-email: move trivial config handling to Perl
    @@ Commit message
         "undef" or "" case (true and false, respectively), let's just punt on
         those and others and have "git config --type=bool" handle it.
     
    +    The "grep { defined } @values" here covers a rather subtle case. For
    +    list values such as sendemail.to it is possible as with any other
    +    config key to provide a plain "-c sendemail.to", i.e. to set the key
    +    as a boolean true. In that case the Git::config() API will return an
    +    empty string, but this new parser will correctly return "undef".
    +
    +    However, that means we can end up with "undef" in the middle of a
    +    list. E.g. for sendemail.smtpserveroption in conjuction with
    +    sendemail.smtpserver as a path this would have produce a warning. For
    +    most of the other keys we'd behave the same despite the subtle change
    +    in the value, e.g. sendemail.to would behave the same because
    +    Mail::Address->parse() happens to return an empty list if fed
    +    "undef". For the boolean values we were already prepared to handle
    +    these variables being initialized as undef anyway.
    +
         This brings the runtime of "git send-email" from ~60-~70ms to a very
         steady ~40ms on my test box. We now run just one "git config"
         invocation on startup instead of 8, the exact number will differ based
    @@ git-send-email.perl: sub read_config {
     -			my @values = Git::config(@repo, $key);
     -			next unless @values;
     +			my @values = @{$known_keys->{$key}};
    ++			@values = grep { defined } @values;
      			next if $configured->{$setting}++;
      			@$target = @values;
      		}
      		else {
     -			my $v = Git::config(@repo, $key);
    --			next unless defined $v;
     +			my $v = $known_keys->{$key}->[0];
    + 			next unless defined $v;
      			next if $configured->{$setting}++;
      			$$target = $v;
    - 		}
     @@ git-send-email.perl: sub config_regexp {
      	my ($regex) = @_;
      	my @ret;
13:  d36b57e429f = 13:  aa3a2de7047 perl: nano-optimize by replacing Cwd::cwd() with Cwd::getcwd()
-- 
2.32.0.rc1.458.gd885d4f985c


  parent reply	other threads:[~2021-05-28  9:23 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 13:48 [PATCH 0/9] send-email: various optimizations to speed up by >2x Ævar Arnfjörð Bjarmason
2021-05-12 13:48 ` [PATCH 1/9] send-email: remove non-working support for "sendemail.smtpssl" Ævar Arnfjörð Bjarmason
2021-05-12 15:46   ` Đoàn Trần Công Danh
2021-05-12 13:48 ` [PATCH 2/9] send-email: refactor sendemail.smtpencryption config parsing Ævar Arnfjörð Bjarmason
2021-05-12 13:48 ` [PATCH 3/9] send-email: lazily load config for a big speedup Ævar Arnfjörð Bjarmason
2021-05-12 13:48 ` [PATCH 4/9] send-email: lazily shell out to "git var" Ævar Arnfjörð Bjarmason
2021-05-12 13:48 ` [PATCH 5/9] send-email: use function syntax instead of barewords Ævar Arnfjörð Bjarmason
2021-05-12 23:11   ` Jeff King
2021-05-12 13:48 ` [PATCH 6/9] send-email: get rid of indirect object syntax Ævar Arnfjörð Bjarmason
2021-05-12 13:48 ` [PATCH 7/9] send-email: lazily load modules for a big speedup Ævar Arnfjörð Bjarmason
2021-05-12 13:48 ` [PATCH 8/9] perl: lazily load some common Git.pm setup code Ævar Arnfjörð Bjarmason
2021-05-12 18:05   ` Eric Wong
2021-05-12 13:48 ` [PATCH 9/9] send-email: move trivial config handling to Perl Ævar Arnfjörð Bjarmason
2021-05-12 19:52   ` Eric Sunshine
2021-05-12 23:08   ` Jeff King
2021-05-13  7:04     ` Felipe Contreras
2021-05-13  7:07       ` Ævar Arnfjörð Bjarmason
2021-05-13  7:26       ` Jeff King
2021-05-13  8:15         ` Felipe Contreras
2021-05-13 11:45           ` Ævar Arnfjörð Bjarmason
2021-05-12 18:04 ` [PATCH 0/9] send-email: various optimizations to speed up by >2x Eric Wong
2021-05-12 23:34 ` Jeff King
2021-05-12 23:36 ` Jeff King
2021-05-13  7:37   ` Ævar Arnfjörð Bjarmason
2021-05-13  7:49     ` Jeff King
2021-05-20  8:18 ` [PATCH v2 00/10] " Ævar Arnfjörð Bjarmason
2021-05-20  8:18   ` [PATCH v2 01/10] send-email: remove non-working support for "sendemail.smtpssl" Ævar Arnfjörð Bjarmason
2021-05-20  8:18   ` [PATCH v2 02/10] send-email: refactor sendemail.smtpencryption config parsing Ævar Arnfjörð Bjarmason
2021-05-20  8:19   ` [PATCH v2 03/10] send-email: lazily load config for a big speedup Ævar Arnfjörð Bjarmason
2021-05-20  8:19   ` [PATCH v2 04/10] send-email: lazily shell out to "git var" Ævar Arnfjörð Bjarmason
2021-05-20  8:19   ` [PATCH v2 05/10] send-email: use function syntax instead of barewords Ævar Arnfjörð Bjarmason
2021-05-20  8:19   ` [PATCH v2 06/10] send-email: get rid of indirect object syntax Ævar Arnfjörð Bjarmason
2021-05-20  8:19   ` [PATCH v2 07/10] send-email: lazily load modules for a big speedup Ævar Arnfjörð Bjarmason
2021-05-20  8:19   ` [PATCH v2 08/10] perl: lazily load some common Git.pm setup code Ævar Arnfjörð Bjarmason
2021-05-20  8:19   ` [PATCH v2 09/10] send-email: move trivial config handling to Perl Ævar Arnfjörð Bjarmason
2021-05-20  8:19   ` [PATCH v2 10/10] perl: nano-optimize by replacing Cwd::cwd() with Cwd::getcwd() Ævar Arnfjörð Bjarmason
2021-05-20  8:27   ` [PATCH v2 00/10] send-email: various optimizations to speed up by >2x Jeff King
2021-05-20 23:53     ` Junio C Hamano
2021-05-21  6:23       ` Ævar Arnfjörð Bjarmason
2021-05-21  7:07         ` Junio C Hamano
2021-05-21  9:13         ` Jeff King
2021-05-21  9:24           ` Ævar Arnfjörð Bjarmason
2021-05-21  9:37             ` Jeff King
2021-05-28 15:49         ` Felipe Contreras
2021-05-29  8:19           ` Ævar Arnfjörð Bjarmason
2021-05-29 14:53             ` Felipe Contreras
2021-05-30 11:33               ` Ævar Arnfjörð Bjarmason
2021-05-30 16:07                 ` Felipe Contreras
2021-05-28 15:12     ` Felipe Contreras
2021-05-23  8:56   ` [PATCH v3 00/13] " Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 01/13] send-email tests: support GIT_TEST_PERL_FATAL_WARNINGS=true Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 02/13] send-email tests: test for boolean variables without a value Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 03/13] send-email: remove non-working support for "sendemail.smtpssl" Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 04/13] send-email: refactor sendemail.smtpencryption config parsing Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 05/13] send-email: copy "config_regxp" into git-send-email.perl Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 06/13] send-email: lazily load config for a big speedup Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 07/13] send-email: lazily shell out to "git var" Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 08/13] send-email: use function syntax instead of barewords Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 09/13] send-email: get rid of indirect object syntax Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 10/13] send-email: lazily load modules for a big speedup Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 11/13] perl: lazily load some common Git.pm setup code Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 12/13] send-email: move trivial config handling to Perl Ævar Arnfjörð Bjarmason
2021-05-23  8:56     ` [PATCH v3 13/13] perl: nano-optimize by replacing Cwd::cwd() with Cwd::getcwd() Ævar Arnfjörð Bjarmason
2021-05-24  1:15     ` [PATCH v3 00/13] send-email: various optimizations to speed up by >2x Junio C Hamano
2021-05-24  7:52     ` [PATCH v4 " Ævar Arnfjörð Bjarmason
2021-05-24  7:52       ` [PATCH v4 01/13] send-email tests: support GIT_TEST_PERL_FATAL_WARNINGS=true Ævar Arnfjörð Bjarmason
2021-05-24  7:52       ` [PATCH v4 02/13] send-email tests: test for boolean variables without a value Ævar Arnfjörð Bjarmason
2021-05-24  7:52       ` [PATCH v4 03/13] send-email: remove non-working support for "sendemail.smtpssl" Ævar Arnfjörð Bjarmason
2021-05-24  7:52       ` [PATCH v4 04/13] send-email: refactor sendemail.smtpencryption config parsing Ævar Arnfjörð Bjarmason
2021-05-24  7:52       ` [PATCH v4 05/13] send-email: copy "config_regxp" into git-send-email.perl Ævar Arnfjörð Bjarmason
2021-05-24  7:52       ` [PATCH v4 06/13] send-email: lazily load config for a big speedup Ævar Arnfjörð Bjarmason
2021-05-24  7:52       ` [PATCH v4 07/13] send-email: lazily shell out to "git var" Ævar Arnfjörð Bjarmason
2021-05-24  7:52       ` [PATCH v4 08/13] send-email: use function syntax instead of barewords Ævar Arnfjörð Bjarmason
2021-05-24  7:52       ` [PATCH v4 09/13] send-email: get rid of indirect object syntax Ævar Arnfjörð Bjarmason
2021-05-24  7:52       ` [PATCH v4 10/13] send-email: lazily load modules for a big speedup Ævar Arnfjörð Bjarmason
2021-05-27  1:11         ` Junio C Hamano
2021-05-27 11:36           ` Ævar Arnfjörð Bjarmason
2021-05-24  7:53       ` [PATCH v4 11/13] perl: lazily load some common Git.pm setup code Ævar Arnfjörð Bjarmason
2021-05-24  7:53       ` [PATCH v4 12/13] send-email: move trivial config handling to Perl Ævar Arnfjörð Bjarmason
2021-05-27 15:57         ` Jeff King
2021-05-24  7:53       ` [PATCH v4 13/13] perl: nano-optimize by replacing Cwd::cwd() with Cwd::getcwd() Ævar Arnfjörð Bjarmason
2021-05-27 16:00       ` [PATCH v4 00/13] send-email: various optimizations to speed up by >2x Jeff King
2021-05-28  9:23       ` Ævar Arnfjörð Bjarmason [this message]
2021-05-28  9:23         ` [PATCH v5 01/13] send-email tests: support GIT_TEST_PERL_FATAL_WARNINGS=true Ævar Arnfjörð Bjarmason
2021-05-28  9:23         ` [PATCH v5 02/13] send-email tests: test for boolean variables without a value Ævar Arnfjörð Bjarmason
2021-07-10 23:23           ` Jeff King
2021-05-28  9:23         ` [PATCH v5 03/13] send-email: remove non-working support for "sendemail.smtpssl" Ævar Arnfjörð Bjarmason
2021-05-28  9:23         ` [PATCH v5 04/13] send-email: refactor sendemail.smtpencryption config parsing Ævar Arnfjörð Bjarmason
2021-05-28  9:23         ` [PATCH v5 05/13] send-email: copy "config_regxp" into git-send-email.perl Ævar Arnfjörð Bjarmason
2021-05-28  9:23         ` [PATCH v5 06/13] send-email: lazily load config for a big speedup Ævar Arnfjörð Bjarmason
2021-05-28  9:23         ` [PATCH v5 07/13] send-email: lazily shell out to "git var" Ævar Arnfjörð Bjarmason
2021-05-28  9:23         ` [PATCH v5 08/13] send-email: use function syntax instead of barewords Ævar Arnfjörð Bjarmason
2021-05-28 16:10           ` Felipe Contreras
2021-05-29  8:17             ` Ævar Arnfjörð Bjarmason
2021-05-29 14:25               ` Felipe Contreras
2021-05-28  9:23         ` [PATCH v5 09/13] send-email: get rid of indirect object syntax Ævar Arnfjörð Bjarmason
2021-05-28  9:23         ` [PATCH v5 10/13] send-email: lazily load modules for a big speedup Ævar Arnfjörð Bjarmason
2021-05-28 15:55           ` Felipe Contreras
2021-05-29  8:12             ` Ævar Arnfjörð Bjarmason
2021-05-29 14:24               ` Felipe Contreras
2021-05-28  9:23         ` [PATCH v5 11/13] perl: lazily load some common Git.pm setup code Ævar Arnfjörð Bjarmason
2021-05-28  9:23         ` [PATCH v5 12/13] send-email: move trivial config handling to Perl Ævar Arnfjörð Bjarmason
2021-05-28  9:23         ` [PATCH v5 13/13] perl: nano-optimize by replacing Cwd::cwd() with Cwd::getcwd() Ævar Arnfjörð Bjarmason
2021-05-28 16:13         ` [PATCH v5 00/13] send-email: various optimizations to speed up by >2x Felipe Contreras
2021-05-31  5:48         ` Jeff King
2021-05-31  9:53           ` Ævar Arnfjörð Bjarmason
2021-05-31 14:38             ` Jeff King
2021-05-27  7:21 ` [PATCH 0/9] " Elijah Newren

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=cover-00.13-00000000000-20210528T092228Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=congdanhqx@gmail.com \
    --cc=e@80x24.org \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=greg@gpanders.com \
    --cc=peff@peff.net \
    --cc=sunshine@sunshineco.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).