<?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 Impact on performance by excessive getenv() in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600622#M619726</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;    There is a process (lets call it our_server). our_server calls getenv() excessively. We have around 500 environment variables which our_server (and all other processes forked off by our_server) might refer to during their time. &lt;BR /&gt;&lt;BR /&gt;Would accessing too many env variables, using getenv() or calling getenv() many times  impact the performance of the process? Is there a better alternative (populating a list and accessing the value from it?) Please suggest. &lt;BR /&gt;&lt;BR /&gt;When a getenv is done, would it do a linear search for the said variable in the list of env variables to fetch the value?&lt;BR /&gt;&lt;BR /&gt;Is it possible to identify (from outside the running program) the most highly used environment variable? [like an alternative for Sun's dtrace on HPUX]&lt;BR /&gt;&lt;BR /&gt;Please let me know. &lt;BR /&gt;&lt;BR /&gt;Thanks! &lt;BR /&gt;raghava</description>
    <pubDate>Mon, 15 Mar 2010 04:50:27 GMT</pubDate>
    <dc:creator>Raghava_1</dc:creator>
    <dc:date>2010-03-15T04:50:27Z</dc:date>
    <item>
      <title>Impact on performance by excessive getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600622#M619726</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;    There is a process (lets call it our_server). our_server calls getenv() excessively. We have around 500 environment variables which our_server (and all other processes forked off by our_server) might refer to during their time. &lt;BR /&gt;&lt;BR /&gt;Would accessing too many env variables, using getenv() or calling getenv() many times  impact the performance of the process? Is there a better alternative (populating a list and accessing the value from it?) Please suggest. &lt;BR /&gt;&lt;BR /&gt;When a getenv is done, would it do a linear search for the said variable in the list of env variables to fetch the value?&lt;BR /&gt;&lt;BR /&gt;Is it possible to identify (from outside the running program) the most highly used environment variable? [like an alternative for Sun's dtrace on HPUX]&lt;BR /&gt;&lt;BR /&gt;Please let me know. &lt;BR /&gt;&lt;BR /&gt;Thanks! &lt;BR /&gt;raghava</description>
      <pubDate>Mon, 15 Mar 2010 04:50:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600622#M619726</guid>
      <dc:creator>Raghava_1</dc:creator>
      <dc:date>2010-03-15T04:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Impact on performance by excessive getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600623#M619727</link>
      <description>Hi , &lt;BR /&gt;&lt;BR /&gt;Not sure , but can the wdb utility be of help.&lt;BR /&gt;&lt;BR /&gt;regards ,&lt;BR /&gt;FrogIsDeaf</description>
      <pubDate>Mon, 15 Mar 2010 07:33:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600623#M619727</guid>
      <dc:creator>DeafFrog</dc:creator>
      <dc:date>2010-03-15T07:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: Impact on performance by excessive getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600624#M619728</link>
      <description>I'm no programmer, but I suspect the _short_ answer to your question is yes it will cause a performance issue (I seem to recall a similar problem in Oracle if you set things up wrong) - Hopefully Dennis H will look at this thread and can probably give you a better answer...&lt;BR /&gt;&lt;BR /&gt;You don't mention whether you're on PA-RISC or Integrity and waht OS version, but assuming you are on Integrity,  for software to get to the bottom of your problem - I'd take a look at caliper...&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.hp.com/go/caliper" target="_blank"&gt;http://www.hp.com/go/caliper&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If you are on HP-UX11iv3 (11.31) you might also want to look and see if the following helps:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1414797" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1414797&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;(although you didn't mention that your app was multi-threaded)&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
      <pubDate>Mon, 15 Mar 2010 08:30:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600624#M619728</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2010-03-15T08:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: Impact on performance by excessive getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600625#M619729</link>
      <description>if you are able to recompile your application  define a &lt;BR /&gt;getenv() which calls _getenv() in your process and count for each program how many time it calls it for every env variable.&lt;BR /&gt;If you can't rebuild there are also some other way to build a shared lib which is preloaded before the libc and overload the getenv() - you also could implement your own hashed getenv() there for instance-&lt;BR /&gt;&lt;BR /&gt;A linear search is indeed made over env variable since it is a unordered table of pointers to different env variables. ( like argv ones but pointed by "char **environ;)&lt;BR /&gt;The search always starts at environ[0]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You can build a new env variable table before calling child processes, setting  the most used first.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Mar 2010 08:35:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600625#M619729</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2010-03-15T08:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Impact on performance by excessive getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600626#M619730</link>
      <description>@laurent &amp;amp;&amp;amp; @duncan: Thanks!&lt;BR /&gt;&lt;BR /&gt;@duncan: This indeed was found using caliper itself. :) caliper reports show that getenv() took a sizable chunk of processing time and hence we started looking into it. But we are not sure if there are only few of those environmental variables which cause this concern. BTW, am working on an HP-UX 11.31 ia64 machine. And our app is not multi-threaded.&lt;BR /&gt;&lt;BR /&gt;@laurent: I would be able to rebuild the whole set of app. &lt;BR /&gt;&amp;gt;&amp;gt;your own hashed getenv()&lt;BR /&gt;That is the idea. We are working on it.&lt;BR /&gt;&lt;BR /&gt;Thanks again!</description>
      <pubDate>Mon, 15 Mar 2010 08:49:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600626#M619730</guid>
      <dc:creator>Raghava_1</dc:creator>
      <dc:date>2010-03-15T08:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Impact on performance by excessive getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600627#M619731</link>
      <description>You don't want to call getenv(3) excessively.  If you call it, you should cache the value.&lt;BR /&gt;&lt;BR /&gt;Each call to getenv(3) has to lock a mutex, if threaded.&lt;BR /&gt;There is an enhanced getenv(3) for performance you can download for 11.31, Getenv-Perf-Enh:&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/5992-3373/ch10s04.html" target="_blank"&gt;http://docs.hp.com/en/5992-3373/ch10s04.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=GetenvPerf" target="_blank"&gt;https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=GetenvPerf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Is there a better alternative (populating a list and accessing the value from it?)&lt;BR /&gt;&lt;BR /&gt;Well, if readonly, copy from your environment to a global variable.  Or if you really need access based on strings, a map.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;When a getenv is done, would it do a linear search for the said variable in the list of env variables to fetch the value?&lt;BR /&gt;&lt;BR /&gt;Yes, unless Getenv-Perf-Enh creates a map?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Is it possible to identify (from outside the running program) the most highly used environment variable?&lt;BR /&gt;&lt;BR /&gt;If you have to identify it, you are making way too many calls to getenv(3)!&lt;BR /&gt;&lt;BR /&gt;&amp;gt;But we are not sure if there are only few of those environmental variables which cause this concern. &lt;BR /&gt;&lt;BR /&gt;I'm not sure you care about "few" or not.  Just don't call getenv(3) so much.  In particular you should NOT be using local time.  I.e. all timestamps should be time_t.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Duncan: you might also want to look and see if the following helps: threadId=1414797&lt;BR /&gt;&lt;BR /&gt;(That's this thread.)</description>
      <pubDate>Mon, 15 Mar 2010 10:28:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600627#M619731</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-03-15T10:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: Impact on performance by excessive getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600628#M619732</link>
      <description>Dennis,&lt;BR /&gt;&lt;BR /&gt;&amp;gt; &amp;gt;Duncan: you might also want to look and &lt;BR /&gt;&amp;gt; see if the following helps: threadId=1414797&lt;BR /&gt;&amp;gt; &lt;BR /&gt;&amp;gt; (That's this thread.) &lt;BR /&gt;&lt;BR /&gt;D'oh! meant to post the link to Getenv-Perf-Enh&lt;BR /&gt;&lt;BR /&gt;Duncan&lt;BR /&gt; &lt;BR /&gt;  &lt;BR /&gt;</description>
      <pubDate>Tue, 16 Mar 2010 15:45:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/impact-on-performance-by-excessive-getenv/m-p/4600628#M619732</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2010-03-16T15:45:51Z</dc:date>
    </item>
  </channel>
</rss>

