<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Performance improvement on perl script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710249#M659840</link>
    <description>Hi Srikanth:&lt;BR /&gt;&lt;BR /&gt;Well it looks like it was *me* who wrote the original version of the script that doesn't scale :-(&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1435953" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1435953&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Mon, 08 Nov 2010 12:13:26 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2010-11-08T12:13:26Z</dc:date>
    <item>
      <title>Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710242#M659833</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a perl script that reads oracle loader log file and extract feedfile to generate an output file. The script is attached. If the size of the feedfile and logfile is limited it works fine. However, when the feedfile is very large in terms of 25GB or 30GB, it gives out of memory error.&lt;BR /&gt;&lt;BR /&gt;The details are&lt;BR /&gt;ops_generate_exception.sh takes in parameter of logfile.&lt;BR /&gt;Within the shell perl script process_exception.pl is called with parameter of formatted logfile and feedfile to generate outputfile called OR-C-DR02-RB002-01-8-HST-EST-20101107-01.&lt;BR /&gt;&lt;BR /&gt;Possibly the perl script reads the entrie feedfile that it gives out of memory in prod environment. Need help to fine tune the perl script please.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Srikanth A</description>
      <pubDate>Sun, 07 Nov 2010 19:18:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710242#M659833</guid>
      <dc:creator>Srikanth Arunachalam</dc:creator>
      <dc:date>2010-11-07T19:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710243#M659834</link>
      <description>Hi Srikanth:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; when the feedfile is very large in terms of 25GB or 30GB, it gives out of memory error.&lt;BR /&gt;&lt;BR /&gt;So is sounds like you are slurping (reading) the whole file into memory.&lt;BR /&gt;&lt;BR /&gt;Please provide your attachment as a simple text one, not as a "*.rar. archive which is non-standard.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sun, 07 Nov 2010 22:57:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710243#M659834</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-11-07T22:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710244#M659835</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;For very large files, I would try the&lt;BR /&gt;following options (if you cannot rewrite&lt;BR /&gt;it in C):&lt;BR /&gt;&lt;BR /&gt;a) Use Tie::File module. The files is not&lt;BR /&gt;loaded into memory and it should work even&lt;BR /&gt;for "gigantic" files.&lt;BR /&gt;&lt;BR /&gt;b) Split your input file into smaller files&lt;BR /&gt;and process them individually. The only bad&lt;BR /&gt;side is that you need more temporary disk&lt;BR /&gt;space.&lt;BR /&gt;&lt;BR /&gt;There are other possibilities too,&lt;BR /&gt;but I would start with the above ones.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;VK2COT&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 07 Nov 2010 23:27:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710244#M659835</guid>
      <dc:creator>VK2COT</dc:creator>
      <dc:date>2010-11-07T23:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710245#M659836</link>
      <description>&amp;gt;&amp;gt; Please provide your attachment as a simple text one, not as a "*.rar. archive which is non-standard.&lt;BR /&gt;&lt;BR /&gt;Yeah, use ZIP if you must, but plain TEXT is preferred by most I guess.&lt;BR /&gt;RAR is a MAC alternative to ZIP.&lt;BR /&gt;&lt;BR /&gt;I could see/extract the contents on windows using the free Stuffit expander: &lt;BR /&gt;&lt;A href="http://www.stuffit.com/win-expander-download.html" target="_blank"&gt;http://www.stuffit.com/win-expander-download.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;JRF&amp;gt; So is sounds like you are slurping (reading) the whole file into memory.&lt;BR /&gt;&lt;BR /&gt;Good guess... Here is the core: &lt;BR /&gt;-----&lt;BR /&gt;{&lt;BR /&gt;    local $/ = undef;&lt;BR /&gt;    @pieces = split( /(?=Record\s+\d+:)/, &amp;lt;&amp;gt; );&lt;BR /&gt;}&lt;BR /&gt;for $line (@pieces) {&lt;BR /&gt;    if ( $line =~ m{(Record\s+(\d+)).+?(ORA.+?)\s}s ) {&lt;BR /&gt;        print $1, "|", $3, "|", $lookup[ $2 - 1 ], "|",$up_amt[ $2 - 1 ],"\n";&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;----&lt;BR /&gt;&lt;BR /&gt;From the perl userguide:&lt;BR /&gt;&lt;BR /&gt;"You may set it ($\ = $RS = $INPUT_RECORD_SEPARATOR in english) to a multi-character string to match a multi-character terminator, or to undef to read through the end of file."&lt;BR /&gt;&lt;BR /&gt;So just change that to a single loop processing records at a time. &lt;BR /&gt;A little more programming, infinitely more scaling.&lt;BR /&gt;&lt;BR /&gt;If you want to tease readers here to help with that then yo may want to provide a TEXT :-) attachment with a hand full of lines from  such log-file containing an example of a record being searched for, and a few lines before and after for good measure.&lt;BR /&gt;&lt;BR /&gt;Btw... why process the data 3 times over?&lt;BR /&gt;1) strip blank&lt;BR /&gt;2) Look for special record&lt;BR /&gt;3) perl.&lt;BR /&gt;&lt;BR /&gt;Perl can do that all in one sweep.&lt;BR /&gt;&lt;BR /&gt;Finally... a pet-peeve of mine:&lt;BR /&gt;&lt;BR /&gt;feedfile=`cat ${formatted_logfile}|grep "Data File"|awk -F':' '{print $2}'`&lt;BR /&gt;&lt;BR /&gt;Yuck! It will be a moot point when you teach the perl script to do it all, but as a general concept why involve CAT and GREP when AWK can do it all?&lt;BR /&gt;Carpenters... Learn to use your tools!&lt;BR /&gt;&lt;BR /&gt;feedfile=$(awk -F':' '/Data File/{print $2}' ${formatted_logfile})&lt;BR /&gt;&lt;BR /&gt;Good luck!&lt;BR /&gt;Hein&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Nov 2010 04:50:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710245#M659836</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-11-08T04:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710246#M659837</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I am attaching each files instead of RAR file. If I am not able to send it in one message, will do it in multiple messages. Please help me in this regard. &lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Srikanth</description>
      <pubDate>Mon, 08 Nov 2010 11:25:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710246#M659837</guid>
      <dc:creator>Srikanth Arunachalam</dc:creator>
      <dc:date>2010-11-08T11:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710247#M659838</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;In my earlier mail, I sent the perl script. I will attach the logfile (passed as first parameter to script now).&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Srikanth A</description>
      <pubDate>Mon, 08 Nov 2010 11:31:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710247#M659838</guid>
      <dc:creator>Srikanth Arunachalam</dc:creator>
      <dc:date>2010-11-08T11:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710248#M659839</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;This is the last attachment. Herewith, I am attaching the feedfile (I have taken only 4 recrds of entire feedfile to avoid oversizeing). This is passed as second parameter to the perl script.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Srikanth</description>
      <pubDate>Mon, 08 Nov 2010 11:34:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710248#M659839</guid>
      <dc:creator>Srikanth Arunachalam</dc:creator>
      <dc:date>2010-11-08T11:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710249#M659840</link>
      <description>Hi Srikanth:&lt;BR /&gt;&lt;BR /&gt;Well it looks like it was *me* who wrote the original version of the script that doesn't scale :-(&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1435953" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1435953&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 08 Nov 2010 12:13:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710249#M659840</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-11-08T12:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710250#M659841</link>
      <description>Hi James,&lt;BR /&gt;&lt;BR /&gt;I do understand that it was your bit of code. Since I started using this, I am simply addicted to it and am trying to come out of lions den. Please show your lion hearted skills to save me from trap.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Srikanth</description>
      <pubDate>Mon, 08 Nov 2010 13:03:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710250#M659841</guid>
      <dc:creator>Srikanth Arunachalam</dc:creator>
      <dc:date>2010-11-08T13:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710251#M659842</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;A quick look back to your original thread indicated that the logfile could be "chunked" into paragraphs as divided by blank lines.  Given this, the original scriptt should be able to be rewritten to:&lt;BR /&gt;&lt;BR /&gt;# cat ./myfilter&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my ( @pieces, $line, @lookup );&lt;BR /&gt;{&lt;BR /&gt;    my $feedfile = 'myfeed';&lt;BR /&gt;    open( my $fh, '&amp;lt;', $feedfile ) or die "Can't open '$feedfile': $!\n";&lt;BR /&gt;    while (&amp;lt;$fh&amp;gt;) {&lt;BR /&gt;        chomp;&lt;BR /&gt;        push( @lookup, substr( $_, 0, 14 ) );&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;    local $/ = "";&lt;BR /&gt;    while (&amp;lt;&amp;gt;) {&lt;BR /&gt;        if ( m{(Record\s+(\d+)).+?(ORA.+?)\sSQL}s ) {&lt;BR /&gt;            print $1, "|", $3, "|", $lookup[ $2 - 1 ], "\n";&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 08 Nov 2010 13:39:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710251#M659842</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-11-08T13:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710252#M659843</link>
      <description>JRF&amp;gt;&amp;gt; Well it looks like it was *me* who wrote the original version of the script that doesn't scale :-(&lt;BR /&gt;&lt;BR /&gt;A good deed never goes unpunished :-)&lt;BR /&gt;&lt;BR /&gt;The original post was actually more clear than this one!&lt;BR /&gt;&lt;BR /&gt;I now realize how the program also reads the whole Oracle feed file. This it probably where it blows up. Please verify by adding a simple 'print' statement after the first loop.&lt;BR /&gt;&lt;BR /&gt;Here is a bit of perl one-liner to do the lookk code job. You could just  merge that into the perl script.&lt;BR /&gt;&lt;BR /&gt;$ perl -ne '$r = $1 if /(^Record\s+\d+:)/; if (/^ORA-/) { print qq($r|$_|) if $r; $r=undef}' tmp.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But I suspect that it blows up on reading the feed file and that the number of errors are more or less under control, the number of data lines not.&lt;BR /&gt;&lt;BR /&gt;So reverse the roles...&lt;BR /&gt;&lt;BR /&gt;Read the LOG file first, establishing an array of error line numbers + ORA text.&lt;BR /&gt;&lt;BR /&gt;Next open the feed file and scan. &lt;BR /&gt;When you read a line for which there is an entry in the error erray, cul the details and print.  ... &lt;BR /&gt;    while &amp;lt;$fh&amp;gt; { &lt;BR /&gt;       next unless $error_line{$.}&lt;BR /&gt;       print ....&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;g2g,&lt;BR /&gt;&lt;BR /&gt;Hein&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Nov 2010 13:59:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710252#M659843</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-11-08T13:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710253#M659844</link>
      <description>No takers? &lt;BR /&gt;No surprise, as it was convoluted enough.&lt;BR /&gt;&lt;BR /&gt;For yucks I rewrote the whole mess as a linear operation, in a single simple perl script.&lt;BR /&gt;No helper files, no helper tools, no arrays.&lt;BR /&gt;I'm sure you'll need to tweak it some, but try.&lt;BR /&gt;&lt;BR /&gt;Script attached.&lt;BR /&gt;&lt;BR /&gt;Outline...&lt;BR /&gt;&lt;BR /&gt;# Get some variables set up&lt;BR /&gt;# Open all files and deal with initial records.&lt;BR /&gt;# Find name of data file in log file.&lt;BR /&gt;# Find log records followed by ORA errors.&lt;BR /&gt;# For each of those Read data file until we find the signalled record&lt;BR /&gt;# Now print the desired data from data record in desired format.&lt;BR /&gt;# loop for next error&lt;BR /&gt;# print final count.&lt;BR /&gt;&lt;BR /&gt;Hein&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Nov 2010 05:26:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710253#M659844</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-11-09T05:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Performance improvement on perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710254#M659845</link>
      <description>Hi Hein and James,&lt;BR /&gt;&lt;BR /&gt;Thanks for your valuable gem of perl expertise in helping me out resolve this issue. I need to tweak a bit. I will complete the requirement and get back to you on this.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Srikanth</description>
      <pubDate>Tue, 09 Nov 2010 11:36:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/performance-improvement-on-perl-script/m-p/4710254#M659845</guid>
      <dc:creator>Srikanth Arunachalam</dc:creator>
      <dc:date>2010-11-09T11:36:32Z</dc:date>
    </item>
  </channel>
</rss>

