From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id D8FAB1F4A7 for ; Sun, 5 May 2019 00:52:19 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/4] DS: drop profiling support Date: Sun, 5 May 2019 00:52:19 +0000 Message-Id: <20190505005219.31772-5-e@80x24.org> In-Reply-To: <20190505005219.31772-1-e@80x24.org> References: <20190505005219.31772-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: There's other ways to profile and we don't need to add runtime branches to do this. --- lib/PublicInbox/DS.pm | 94 ------------------------------------------- 1 file changed, 94 deletions(-) diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index f181eee..7bd5d42 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -13,8 +13,6 @@ use bytes; use POSIX (); use Time::HiRes (); -my $opt_bsd_resource = eval "use BSD::Resource; 1;"; - use vars qw{$VERSION}; $VERSION = "1.61"; @@ -63,8 +61,6 @@ our ( %PLCMap, # fd (num) -> PostLoopCallback (per-object) $LoopTimeout, # timeout of event loop in milliseconds - $DoProfile, # if on, enable profiling - %Profiling, # what => [ utime, stime, calls ] $DoneInit, # if we've done the one-time module init yet @Timers, # timers ); @@ -87,8 +83,6 @@ sub Reset { @ToClose = (); %OtherFds = (); $LoopTimeout = -1; # no timeout by default - $DoProfile = 0; - %Profiling = (); @Timers = (); $PostLoopCallback = undef; @@ -122,40 +116,6 @@ sub WatchedSockets { } *watched_sockets = *WatchedSockets; -=head2 C<< CLASS->EnableProfiling() >> - -Turns profiling on, clearing current profiling data. - -=cut -sub EnableProfiling { - if ($opt_bsd_resource) { - %Profiling = (); - $DoProfile = 1; - return 1; - } - return 0; -} - -=head2 C<< CLASS->DisableProfiling() >> - -Turns off profiling, but retains data up to this point - -=cut -sub DisableProfiling { - $DoProfile = 0; -} - -=head2 C<< CLASS->ProfilingData() >> - -Returns reference to a hash of data in format: - - ITEM => [ utime, stime, #calls ] - -=cut -sub ProfilingData { - return \%Profiling; -} - =head2 C<< CLASS->ToClose() >> Return the list of sockets that are awaiting close() at the end of the @@ -306,28 +266,6 @@ sub FirstTimeEventLoop { } } -## profiling-related data/functions -our ($Prof_utime0, $Prof_stime0); -sub _pre_profile { - ($Prof_utime0, $Prof_stime0) = getrusage(); -} - -sub _post_profile { - # get post information - my ($autime, $astime) = getrusage(); - - # calculate differences - my $utime = $autime - $Prof_utime0; - my $stime = $astime - $Prof_stime0; - - foreach my $k (@_) { - $Profiling{$k} ||= [ 0.0, 0.0, 0 ]; - $Profiling{$k}->[0] += $utime; - $Profiling{$k}->[1] += $stime; - $Profiling{$k}->[2]++; - } -} - # runs timers and returns milliseconds for next one, or next event loop sub RunTimers { return $LoopTimeout unless @Timers; @@ -404,38 +342,6 @@ sub EpollEventLoop { DebugLevel >= 1 && $class->DebugMsg("Event: fd=%d (%s), state=%d \@ %s\n", $ev->[0], ref($pob), $ev->[1], time); - if ($DoProfile) { - my $class = ref $pob; - - # call profiling action on things that need to be done - if ($state & EPOLLIN && ! $pob->{closed}) { - _pre_profile(); - $pob->event_read; - _post_profile("$class-read"); - } - - if ($state & EPOLLOUT && ! $pob->{closed}) { - _pre_profile(); - $pob->event_write; - _post_profile("$class-write"); - } - - if ($state & (EPOLLERR|EPOLLHUP)) { - if ($state & EPOLLERR && ! $pob->{closed}) { - _pre_profile(); - $pob->event_err; - _post_profile("$class-err"); - } - if ($state & EPOLLHUP && ! $pob->{closed}) { - _pre_profile(); - $pob->event_hup; - _post_profile("$class-hup"); - } - } - - next; - } - # standard non-profiling codepat $pob->event_read if $state & EPOLLIN && ! $pob->{closed}; $pob->event_write if $state & EPOLLOUT && ! $pob->{closed}; -- EW