[rrd-users] Performance problem in RRDp.pm
Bjorn Nordbo
bn at nextel.no
Tue Dec 14 15:40:50 MET 1999
I hope this is the right place to ask.
I have hacked rrdtool into MRTG for normal operation (ie. for batch
generation of graphs). This seems to work relatively ok now, but it
is not by far as fast as I had hoped.
I use RRDp.pm to talk with rrdtool, and the performance problem is
in this module, more specificly the read function. I have tried to
understand this code, and though I see that it uses non-blocking IO,
its operation is not entirely clear to me.
I anyone could give me a summary of operation for this function, I
would be most happy. And if anyone has suggestions for performance
improvmance, please tell me! :)
This is the results of profiling a large session with SmallProf.pm.
Only RRDp::read() is included. The select itself is not visible, but
the line is marked with stars.
380 0.000000 0.000000 128:sub read () {
380 0.439632 0.060000 129: croak "RRDp::read can only be called after
0 0.000000 0.000000 130: unless $Sequence eq 'C';
380 0.000912 0.020000 131: $Sequence = 'R';
380 0.001382 0.000000 132: my $inmask = 0;
380 0.004526 0.010000 133: my $srbuf;
380 0.001269 0.010000 134: my $minibuf;
380 0.001280 0.040000 135: my $buffer;
380 0.001952 0.010000 136: my $nfound;
380 0.001194 0.030000 137: my $timeleft;
380 0.063653 0.030000 138: my $ERR = 0;
380 0.002133 0.010000 139: vec($inmask,fileno(RRDreadHand),1) = 1; #
380 0.009915 0.010000 140: while (1) {
380 0.001219 0.030000 141: my $rout;
**** 380 329.1268 0.060000 142: $nfound =
380 0.001554 0.030000 143: if ($nfound == 0 ) {
0 0.000000 0.000000 144: # here, we could do something sensible
0 0.000000 0.000000 145: next;
0 0.000000 0.000000 146: }
380 0.003149 0.070000 147: sysread(RRDreadHand,$srbuf,4096);
380 0.001077 0.030000 148: $minibuf .= $srbuf;
684 0.008893 0.080000 149: while ($minibuf =~ s|^(.+?)\n||s) {
684 0.002251 0.050000 150: my $line = $1;
0 0.000000 0.000000 151: # print $line,"\n";
684 0.005111 0.020000 152: if ($line =~ m|^ERROR|) {
0 0.000000 0.000000 153: croak $line;
0 0.000000 0.000000 154: $ERR = 1;
0 0.000000 0.000000 155: }
684 0.001907 0.020000 156: elsif ($line =~ m|^OK u:([\d\.]+)
380 0.001137 0.010000 157:
380 0.010874 0.040000 158: return $ERR == 1 ? undef : \$buffer;
0 0.000000 0.000000 159: } else {
304 0.002021 0.030000 160: $buffer .= $line. "\n";
0 0.000000 0.000000 161: }
0 0.000000 0.000000 162: }
0 0.000000 0.000000 163: }
0 0.000000 0.000000 164:}
Thanks in advance!
Bjørn
--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
More information about the rrd-users
mailing list