user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 3/3] git: reduce stat buffer storage overhead
  2020-04-05  7:53  4% [PATCH 0/3] some efficiency improvements Eric Wong
@ 2020-04-05  7:53  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-04-05  7:53 UTC (permalink / raw)
  To: meta

The stat() array is a whopping 480 bytes (on x86-64, Perl 5.28),
while the new packed representation of two 64-bit doubles as a
scalar is "only" 56 bytes.  This can add up when there's many
inboxes.  Just use a string comparison on the packed
representation.

Some 32-bit Perl builds (IIRC OpenBSD) lack quad support, so
doubles were chosen for pack() portability.
---
 lib/PublicInbox/Git.pm | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 9c96b3f0..8410b2fc 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -55,10 +55,8 @@ sub git_quote ($) {
 
 sub new {
 	my ($class, $git_dir) = @_;
-	my @st;
-	$st[7] = $st[10] = 0;
 	# may contain {-tmp} field for File::Temp::Dir
-	bless { git_dir => $git_dir, st => \@st, -git_path => {} }, $class
+	bless { git_dir => $git_dir, alt_st => '', -git_path => {} }, $class
 }
 
 sub git_path ($$) {
@@ -79,10 +77,11 @@ sub alternates_changed {
 	my ($self) = @_;
 	my $alt = git_path($self, 'objects/info/alternates');
 	my @st = stat($alt) or return 0;
-	my $old_st = $self->{st};
-	# 10 - ctime, 7 - size
-	return 0 if ($st[10] == $old_st->[10] && $st[7] == $old_st->[7]);
-	$self->{st} = \@st;
+
+	# can't rely on 'q' on some 32-bit builds, but `d' works
+	my $st = pack('dd', $st[10], $st[7]); # 10: ctime, 7: size
+	return 0 if $self->{alt_st} eq $st;
+	$self->{alt_st} = $st; # always a true value
 }
 
 sub last_check_err {

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/3] some efficiency improvements
@ 2020-04-05  7:53  4% Eric Wong
  2020-04-05  7:53  7% ` [PATCH 3/3] git: reduce stat buffer storage overhead Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-04-05  7:53 UTC (permalink / raw)
  To: meta

[1/3] I seem to forget every decade or so that `$sv = undef'
and `undef $sv' have different behaviors.  Sometimes I want
the former, but here I want the latter.

I'm not entirely happy with [2/3], but the worst case is
theoretically better than before.  I really wish Perl
and PSGI could support things like writev+sendmmsg
well.

[3/3] will make some difference with many inboxes.

Eric Wong (3):
  release large (non ref) scalars using `undef $sv'
  mbox: halve ->getline "context switches"
  git: reduce stat buffer storage overhead

 lib/PublicInbox/Git.pm       | 13 ++++++-------
 lib/PublicInbox/Mbox.pm      |  9 +++------
 lib/PublicInbox/SearchIdx.pm | 33 ++++++++++++++++-----------------
 lib/PublicInbox/View.pm      |  4 ++--
 lib/PublicInbox/ViewDiff.pm  |  2 +-
 5 files changed, 28 insertions(+), 33 deletions(-)

^ permalink raw reply	[relevance 4%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-04-05  7:53  4% [PATCH 0/3] some efficiency improvements Eric Wong
2020-04-05  7:53  7% ` [PATCH 3/3] git: reduce stat buffer storage overhead Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).