user/dev discussion of public-inbox itself
 help / color / Atom feed
From: Eric Wong <e@80x24.org>
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> (raw)
In-Reply-To: <20190505005219.31772-1-e@80x24.org>

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


  parent reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-05  0:52 [PATCH 0/4] bundle Danga::Socket and Sys::Syscall Eric Wong
2019-05-05  0:52 ` [PATCH 1/4] " Eric Wong
2019-05-05  4:56   ` [PATCH 5/4] DS: workaround IO::Kqueue EINTR (mis-)handling Eric Wong
2019-05-08  9:07   ` [PATCH 6/4] DS: handle EINTR in IO::Poll path, too Eric Wong
2019-05-05  0:52 ` [PATCH 2/4] listener: use EPOLLEXCLUSIVE for listen sockets Eric Wong
2019-05-05  0:52 ` [PATCH 3/4] DS: remove unused fields and functions Eric Wong
2019-05-05  0:52 ` Eric Wong [this message]
2019-05-08 19:18 ` [PATCH 0/4] Danga::Socket bundling cleanups Eric Wong
2019-05-08 19:18   ` [PATCH 1/4] build: do not manify DS and Syscall pods Eric Wong
2019-05-08 19:18   ` [PATCH 2/4] syscall: drop readahead wrapper Eric Wong
2019-05-08 19:18   ` [PATCH 3/4] DS: drop unused "_undef" sub Eric Wong
2019-05-08 19:18   ` [PATCH 4/4] DS: epoll: fix misordered EPOLL_CTL_DEL call Eric Wong

Reply instructions:

You may reply publically 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

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190505005219.31772-5-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /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

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.org/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox