git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v5 00/13] send-email: various optimizations to speed up by >2x

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 28, 2021, 09:23 UTC
Message-ID
<cover-00.13-00000000000-20210528T092228Z-avarab@gmail.com>
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
Previous: Jeff KingNext: Ævar Arnfjörð Bjarmason
Message 83 of 108 in “send-email: various optimizations to speed up by >2x”
  1. 0/9 send-email: various optimizations to speed up by >2xÆvar Arnfjörð Bjarmason, May 12, 2021
  2. 1/9 send-email: remove non-working support for "sendemail.smtpssl"Ævar Arnfjörð Bjarmason, May 12, 2021
  3. Đoàn Trần Công DanhMay 12, 2021
  4. 2/9 send-email: refactor sendemail.smtpencryption config parsingÆvar Arnfjörð Bjarmason, May 12, 2021
  5. 3/9 send-email: lazily load config for a big speedupÆvar Arnfjörð Bjarmason, May 12, 2021
  6. 4/9 send-email: lazily shell out to "git var"Ævar Arnfjörð Bjarmason, May 12, 2021
  7. 5/9 send-email: use function syntax instead of barewordsÆvar Arnfjörð Bjarmason, May 12, 2021
  8. Jeff KingMay 12, 2021
  9. 6/9 send-email: get rid of indirect object syntaxÆvar Arnfjörð Bjarmason, May 12, 2021
  10. 7/9 send-email: lazily load modules for a big speedupÆvar Arnfjörð Bjarmason, May 12, 2021
  11. 8/9 perl: lazily load some common Git.pm setup codeÆvar Arnfjörð Bjarmason, May 12, 2021
  12. Eric WongMay 12, 2021
  13. 9/9 send-email: move trivial config handling to PerlÆvar Arnfjörð Bjarmason, May 12, 2021
  14. Eric SunshineMay 12, 2021
  15. Jeff KingMay 12, 2021
  16. Felipe ContrerasMay 13, 2021
  17. Jeff KingMay 13, 2021
  18. Felipe ContrerasMay 13, 2021
  19. Ævar Arnfjörð BjarmasonMay 13, 2021
  20. Ævar Arnfjörð BjarmasonMay 13, 2021
  21. Eric WongMay 12, 2021
  22. Jeff KingMay 12, 2021
  23. Jeff KingMay 12, 2021
  24. Ævar Arnfjörð BjarmasonMay 13, 2021
  25. Jeff KingMay 13, 2021
  26. 00/10 send-email: various optimizations to speed up by >2xÆvar Arnfjörð Bjarmason, May 20, 2021
  27. 01/10 send-email: remove non-working support for "sendemail.smtpssl"Ævar Arnfjörð Bjarmason, May 20, 2021
  28. 02/10 send-email: refactor sendemail.smtpencryption config parsingÆvar Arnfjörð Bjarmason, May 20, 2021
  29. 03/10 send-email: lazily load config for a big speedupÆvar Arnfjörð Bjarmason, May 20, 2021
  30. 04/10 send-email: lazily shell out to "git var"Ævar Arnfjörð Bjarmason, May 20, 2021
  31. 05/10 send-email: use function syntax instead of barewordsÆvar Arnfjörð Bjarmason, May 20, 2021
  32. 06/10 send-email: get rid of indirect object syntaxÆvar Arnfjörð Bjarmason, May 20, 2021
  33. 08/10 perl: lazily load some common Git.pm setup codeÆvar Arnfjörð Bjarmason, May 20, 2021
  34. 07/10 send-email: lazily load modules for a big speedupÆvar Arnfjörð Bjarmason, May 20, 2021
  35. 10/10 perl: nano-optimize by replacing Cwd::cwd() with Cwd::getcwd()Ævar Arnfjörð Bjarmason, May 20, 2021
  36. 09/10 send-email: move trivial config handling to PerlÆvar Arnfjörð Bjarmason, May 20, 2021
  37. Jeff KingMay 20, 2021
  38. Junio C HamanoMay 20, 2021
  39. Ævar Arnfjörð BjarmasonMay 21, 2021
  40. Junio C HamanoMay 21, 2021
  41. Jeff KingMay 21, 2021
  42. Ævar Arnfjörð BjarmasonMay 21, 2021
  43. Jeff KingMay 21, 2021
  44. Felipe ContrerasMay 28, 2021
  45. Ævar Arnfjörð BjarmasonMay 29, 2021
  46. Felipe ContrerasMay 29, 2021
  47. Ævar Arnfjörð BjarmasonMay 30, 2021
  48. Felipe ContrerasMay 30, 2021
  49. Felipe ContrerasMay 28, 2021
  50. 00/13 send-email: various optimizations to speed up by >2xÆvar Arnfjörð Bjarmason, May 23, 2021
  51. 01/13 send-email tests: support GIT_TEST_PERL_FATAL_WARNINGS=trueÆvar Arnfjörð Bjarmason, May 23, 2021
  52. 02/13 send-email tests: test for boolean variables without a valueÆvar Arnfjörð Bjarmason, May 23, 2021
  53. 03/13 send-email: remove non-working support for "sendemail.smtpssl"Ævar Arnfjörð Bjarmason, May 23, 2021
  54. 04/13 send-email: refactor sendemail.smtpencryption config parsingÆvar Arnfjörð Bjarmason, May 23, 2021
  55. 05/13 send-email: copy "config_regxp" into git-send-email.perlÆvar Arnfjörð Bjarmason, May 23, 2021
  56. 06/13 send-email: lazily load config for a big speedupÆvar Arnfjörð Bjarmason, May 23, 2021
  57. 07/13 send-email: lazily shell out to "git var"Ævar Arnfjörð Bjarmason, May 23, 2021
  58. 09/13 send-email: get rid of indirect object syntaxÆvar Arnfjörð Bjarmason, May 23, 2021
  59. 08/13 send-email: use function syntax instead of barewordsÆvar Arnfjörð Bjarmason, May 23, 2021
  60. 10/13 send-email: lazily load modules for a big speedupÆvar Arnfjörð Bjarmason, May 23, 2021
  61. 11/13 perl: lazily load some common Git.pm setup codeÆvar Arnfjörð Bjarmason, May 23, 2021
  62. 12/13 send-email: move trivial config handling to PerlÆvar Arnfjörð Bjarmason, May 23, 2021
  63. 13/13 perl: nano-optimize by replacing Cwd::cwd() with Cwd::getcwd()Ævar Arnfjörð Bjarmason, May 23, 2021
  64. Junio C HamanoMay 24, 2021
  65. 00/13 send-email: various optimizations to speed up by >2xÆvar Arnfjörð Bjarmason, May 24, 2021
  66. 01/13 send-email tests: support GIT_TEST_PERL_FATAL_WARNINGS=trueÆvar Arnfjörð Bjarmason, May 24, 2021
  67. 02/13 send-email tests: test for boolean variables without a valueÆvar Arnfjörð Bjarmason, May 24, 2021
  68. 03/13 send-email: remove non-working support for "sendemail.smtpssl"Ævar Arnfjörð Bjarmason, May 24, 2021
  69. 04/13 send-email: refactor sendemail.smtpencryption config parsingÆvar Arnfjörð Bjarmason, May 24, 2021
  70. 07/13 send-email: lazily shell out to "git var"Ævar Arnfjörð Bjarmason, May 24, 2021
  71. 06/13 send-email: lazily load config for a big speedupÆvar Arnfjörð Bjarmason, May 24, 2021
  72. 05/13 send-email: copy "config_regxp" into git-send-email.perlÆvar Arnfjörð Bjarmason, May 24, 2021
  73. 09/13 send-email: get rid of indirect object syntaxÆvar Arnfjörð Bjarmason, May 24, 2021
  74. 10/13 send-email: lazily load modules for a big speedupÆvar Arnfjörð Bjarmason, May 24, 2021
  75. Junio C HamanoMay 27, 2021
  76. Ævar Arnfjörð BjarmasonMay 27, 2021
  77. 11/13 perl: lazily load some common Git.pm setup codeÆvar Arnfjörð Bjarmason, May 24, 2021
  78. 12/13 send-email: move trivial config handling to PerlÆvar Arnfjörð Bjarmason, May 24, 2021
  79. Jeff KingMay 27, 2021
  80. 08/13 send-email: use function syntax instead of barewordsÆvar Arnfjörð Bjarmason, May 24, 2021
  81. 13/13 perl: nano-optimize by replacing Cwd::cwd() with Cwd::getcwd()Ævar Arnfjörð Bjarmason, May 24, 2021
  82. Jeff KingMay 27, 2021
  83. 00/13 send-email: various optimizations to speed up by >2xÆvar Arnfjörð Bjarmason, May 28, 2021
  84. 01/13 send-email tests: support GIT_TEST_PERL_FATAL_WARNINGS=trueÆvar Arnfjörð Bjarmason, May 28, 2021
  85. 03/13 send-email: remove non-working support for "sendemail.smtpssl"Ævar Arnfjörð Bjarmason, May 28, 2021
  86. 02/13 send-email tests: test for boolean variables without a valueÆvar Arnfjörð Bjarmason, May 28, 2021
  87. Jeff KingJul 10, 2021
  88. 04/13 send-email: refactor sendemail.smtpencryption config parsingÆvar Arnfjörð Bjarmason, May 28, 2021
  89. 06/13 send-email: lazily load config for a big speedupÆvar Arnfjörð Bjarmason, May 28, 2021
  90. 05/13 send-email: copy "config_regxp" into git-send-email.perlÆvar Arnfjörð Bjarmason, May 28, 2021
  91. 07/13 send-email: lazily shell out to "git var"Ævar Arnfjörð Bjarmason, May 28, 2021
  92. 09/13 send-email: get rid of indirect object syntaxÆvar Arnfjörð Bjarmason, May 28, 2021
  93. 08/13 send-email: use function syntax instead of barewordsÆvar Arnfjörð Bjarmason, May 28, 2021
  94. Felipe ContrerasMay 28, 2021
  95. Ævar Arnfjörð BjarmasonMay 29, 2021
  96. Felipe ContrerasMay 29, 2021
  97. 10/13 send-email: lazily load modules for a big speedupÆvar Arnfjörð Bjarmason, May 28, 2021
  98. Felipe ContrerasMay 28, 2021
  99. Ævar Arnfjörð BjarmasonMay 29, 2021
  100. Felipe ContrerasMay 29, 2021
  101. 12/13 send-email: move trivial config handling to PerlÆvar Arnfjörð Bjarmason, May 28, 2021
  102. 11/13 perl: lazily load some common Git.pm setup codeÆvar Arnfjörð Bjarmason, May 28, 2021
  103. 13/13 perl: nano-optimize by replacing Cwd::cwd() with Cwd::getcwd()Ævar Arnfjörð Bjarmason, May 28, 2021
  104. Felipe ContrerasMay 28, 2021
  105. Jeff KingMay 31, 2021
  106. Ævar Arnfjörð BjarmasonMay 31, 2021
  107. Jeff KingMay 31, 2021
  108. Elijah NewrenMay 27, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.