<!-- 
RSS generated by JIRA (8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b) at Sat Feb 10 15:48:43 JST 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>PFS-JIRA</title>
    <link>https://pfspipe.ipmu.jp/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>8.3.4</version>
        <build-number>803005</build-number>
        <build-date>13-09-2019</build-date>
    </build-info>


<item>
            <title>[PIPE2D-127] Profile the pipeline</title>
                <link>https://pfspipe.ipmu.jp/jira/browse/PIPE2D-127</link>
                <project id="10002" key="PIPE2D">DRP 2-D Pipeline</project>
                    <description>&lt;p&gt;Profile the pipeline to identify hotspots and low-hanging fruit.&lt;/p&gt;</description>
                <environment></environment>
        <key id="11343">PIPE2D-127</key>
            <summary>Profile the pipeline</summary>
                <type id="10001" iconUrl="https://pfspipe.ipmu.jp/jira/secure/viewavatar?size=xsmall&amp;avatarId=10515&amp;avatarType=issuetype">Story</type>
                                            <priority id="3" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/priorities/major.svg">Major</priority>
                        <status id="10002" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/statuses/generic.png" description="The issue is resolved, reviewed, and merged">Done</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10000">Done</resolution>
                                        <assignee username="price">price</assignee>
                                    <reporter username="price">price</reporter>
                        <labels>
                    </labels>
                <created>Fri, 18 Nov 2016 18:34:03 +0000</created>
                <updated>Thu, 22 Jun 2017 20:30:35 +0000</updated>
                            <resolved>Thu, 22 Jun 2017 20:30:35 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                <comments>
                            <comment id="11658" author="price" created="Fri, 2 Dec 2016 20:37:29 +0000"  >&lt;p&gt;I&apos;ll post the details soon, but here are the main results:&lt;/p&gt;

&lt;p&gt;General gains could be made by looking at ISR:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;tt&gt;calcEffectiveGain&lt;/tt&gt;, &lt;tt&gt;setGain&lt;/tt&gt; aren&apos;t useful in my opinion&lt;/li&gt;
	&lt;li&gt;Statistics gets called a lot, for the same kind of need (background level)&lt;/li&gt;
	&lt;li&gt;Need to investigate remaining parts (CCD assembly, interpolation) to see if we can squeeze some performance&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;&lt;tt&gt;pfs::drp::stella::findCenterPositionsOneTrace&lt;/tt&gt; is calling &lt;tt&gt;pfs::drp::stella::math::insertSorted&lt;/tt&gt;, which is calling &lt;tt&gt;std::vector::insert&lt;/tt&gt;. In general, you should never use &lt;tt&gt;std::vector::insert&lt;/tt&gt;. cplusplus.com says:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Because vectors use an array as their underlying storage, inserting elements in positions other than the vector end causes the container to relocate all the elements that were after position to their new positions. This is generally an inefficient operation compared to the one performed for the same operation by other kinds of sequence containers (such as list or forward_list).&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Instead, push everything onto the end of the &lt;tt&gt;std::vector&lt;/tt&gt; and then use &lt;tt&gt;std::sort&lt;/tt&gt; at the end.  Or use a list instead of an array, but that may have performance implications in other places.&lt;/p&gt;

&lt;p&gt;Cache the &lt;tt&gt;end()&lt;/tt&gt; iterator in loops over &lt;tt&gt;ndarray&lt;/tt&gt; (especially 2D arrays, which have more complicated iterators) because that&apos;s showing up in the profiles.&lt;/p&gt;

&lt;p&gt;In &lt;tt&gt;ReduceArcTask&lt;/tt&gt;, this snippet is using the lion&apos;s share of the runtime:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   165  30412812     67429737      2.2     30.5                  &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; j in range(traceIds.shape[0]):
   166  30412800     72818425      2.4     32.9                      &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; traceIds[j] != l:
   167      7200        16710      2.3      0.0                          l = traceIds[j]
   168  30412800     74841313      2.5     33.8                      &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; traceIds[j] == traceIdsUnique[traceId]:
   169     50688       125401      2.5      0.1                          wLenTemp[k] = wavelengths[j]
   170     50688       116528      2.3      0.1                          k = k+1
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;tt&gt;l&lt;/tt&gt; isn&apos;t used for anything, so can immediately save 33%.&lt;/li&gt;
	&lt;li&gt;Use an iterator for clarity and to save dereferencing everything, e.g., &lt;tt&gt;for trace in traceIds&lt;/tt&gt;&lt;/li&gt;
	&lt;li&gt;Iterating over individual vector (or image) values in python is something to avoid like the plague.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The code is clearer and faster (18.774 sec --&amp;gt; 6.077 sec) if written as:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
                    indices = np.where(traceIds == traceIdsUnique[traceId])[0]
                    &lt;span class=&quot;code-keyword&quot;&gt;assert&lt;/span&gt; len(indices) == len(wLenTemp)
                    wLenTemp[:] = wavelengths[indices]
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(The &lt;tt&gt;assert&lt;/tt&gt; is there because it wasn&apos;t obvious to me that the two vectors should have the same length &amp;#8212; I suggest checking the original assignment of &lt;tt&gt;wLenTemp&lt;/tt&gt;. In fact, you could drop the &lt;tt&gt;assert&lt;/tt&gt;, the original assignment of &lt;tt&gt;wLenTemp&lt;/tt&gt; and the &lt;tt&gt;[:]&lt;/tt&gt; in the above and it should work just fine, even a tad faster.)&lt;/p&gt;

&lt;p&gt;Some additional thoughts:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;fiberTrace files are being read using pyfits. Can we use &lt;tt&gt;lsst::afw::table&lt;/tt&gt; instead? pyfits is notoriously slow.&lt;/li&gt;
	&lt;li&gt;Why is there a single fiberTrace for all time, rather than versioning it like a bias or flat?&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="11659" author="price" created="Fri, 2 Dec 2016 20:40:16 +0000"  >&lt;p&gt;Oh, and I forgot to mention, constructDark is taking a long time hunting cosmics (190 of 224 sec), which seems excessive.&lt;/p&gt;</comment>
                            <comment id="11660" author="price" created="Fri, 2 Dec 2016 20:45:28 +0000"  >&lt;p&gt;Details are attached in &lt;tt&gt;profile.txt&lt;/tt&gt;.&lt;/p&gt;</comment>
                            <comment id="11661" author="price" created="Fri, 2 Dec 2016 20:49:04 +0000"  >&lt;p&gt;Code changes made as part of this work:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
price@price-laptop:~/PFS/pfs_pipe2d (tickets/PIPE2D-127=) $ git sub
commit 116be6508ce3f6f0f201fce6e458b279aadfaa3e
Author: Paul Price &amp;lt;price@astro.princeton.edu&amp;gt;
Date:   Thu Dec 1 15:06:37 2016 -0500

    add support &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; python profiling in integration test

 bin/pfs_integration_test.sh | 45 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 36 insertions(+), 9 deletions(-)

commit 79bd9dd1d94526023d5d07f25884ef221dc74bef
Author: Paul Price &amp;lt;price@astro.princeton.edu&amp;gt;
Date:   Fri Dec 2 08:46:07 2016 -0500

    travis: build with 2 cores

 bin/pfs_travis.sh | 2 ++
 1 file changed, 2 insertions(+)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="11662" author="price" created="Fri, 2 Dec 2016 20:50:17 +0000"  >&lt;p&gt;And:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
price@price-laptop:~/PFS/obs_pfs (tickets/PIPE2D-127=) $ git sub
commit 2377391fc9c0875d8914eee93611b8154e7e2ebf
Author: Paul Price &amp;lt;price@astro.princeton.edu&amp;gt;
Date:   Thu Dec 1 17:19:25 2016 -0500

    ingest: clean up &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; style

 python/lsst/obs/pfs/ingest.py | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="11677" author="price" created="Tue, 6 Dec 2016 14:36:39 +0000"  >&lt;p&gt;&lt;a href=&quot;https://pfspipe.ipmu.jp/jira/secure/ViewProfile.jspa?name=rhl&quot; class=&quot;user-hover&quot; rel=&quot;rhl&quot;&gt;rhl&lt;/a&gt;, could you please verify this is the level of detail you were after?  I haven&apos;t yet made tickets to implement these suggestions.  Would you like multiple tickets or one ticket to rule them all?&lt;/p&gt;</comment>
                            <comment id="11916" author="rhl" created="Fri, 24 Feb 2017 18:04:37 +0000"  >&lt;p&gt;That&apos;s useful.  I don&apos;t know how &lt;a href=&quot;https://pfspipe.ipmu.jp/jira/secure/ViewProfile.jspa?name=swinbank&quot; class=&quot;user-hover&quot; rel=&quot;swinbank&quot;&gt;swinbank&lt;/a&gt; wants to track this, but probably creating the tickets would be useful&lt;/p&gt;</comment>
                            <comment id="11917" author="swinbank" created="Sat, 25 Feb 2017 00:03:47 +0000"  >&lt;p&gt;Please go ahead and create multiple tickets.&lt;/p&gt;</comment>
                            <comment id="12291" author="rhl" created="Thu, 22 Jun 2017 20:30:08 +0000"  >&lt;p&gt;I think we need to close this &amp;#8211; you did the work.  I&apos;ll open a new ticket to repeat the work with multiprocessing turned off (&lt;tt&gt;--batch-type None&lt;/tt&gt;) and hope/pray that some of the hot spots have been eliminated.&lt;/p&gt;

&lt;p&gt;Also, we should process the &lt;tt&gt;runPipeline&lt;/tt&gt; script.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="10402" name="profile.txt" size="52582" author="price" created="Fri, 2 Dec 2016 20:45:08 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                            <customfield id="customfield_10500" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|ii011b:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10100" key="com.atlassian.jira.plugin.system.customfieldtypes:userpicker">
                        <customfieldname>Reviewers</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>rhl</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10005" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="22">2014-16</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    </customfields>
    </item>
</channel>
</rss>