<!-- 
RSS generated by JIRA (4.4#649-r158309) at Tue May 21 14:02:08 CDT 2013

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 add field=key&field=summary to the URL of your request.
For example:
http://dev.clojure.org/jira/si/jira.issueviews:issue-xml/NREPL-8/NREPL-8.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Clojure JIRA</title>
    <link>http://dev.clojure.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>4.4</version>
        <build-number>649</build-number>
        <build-date>25-07-2011</build-date>
    </build-info>

<item>
            <title>[NREPL-8] set stack size for Android</title>
                <link>http://dev.clojure.org/jira/browse/NREPL-8</link>
                <project id="10022" key="NREPL">tools.nrepl</project>
                        <description>&lt;p&gt;If you want to use nREPL on Android (currently only possible with sattvik&apos;s fork of Clojure) then you need bigger stack sizes than Android&apos;s default 8k to eval even moderately complex expressions. For comparison: A regular JVM on a PC has default stack sizes around 256k ... 512k depending on platform.&lt;/p&gt;

&lt;p&gt;In nrepl.clj, modify&lt;/p&gt;

&lt;p&gt;(doto (Thread. r)&lt;br/&gt;
  (.setDaemon true))))))&lt;/p&gt;

&lt;p&gt;to read&lt;/p&gt;

&lt;p&gt;(doto (Thread. (.getThreadGroup (Thread/currentThread)) r &quot;nREPL&quot; 524288)  ; 512k generous stack size&lt;br/&gt;
  (.setDaemon true))))))&lt;/p&gt;

&lt;p&gt;Note: There are warnings here &lt;a href=&quot;http://bit.ly/u86tF1&quot;&gt;http://bit.ly/u86tF1&lt;/a&gt; about choosing a good stack size but since in practice nREPL seems to have &amp;lt;10 threads running with 1 active client connection we can be generous here.&lt;/p&gt;

&lt;p&gt;The more advanced version would be to make this somehow configurable but that&apos;d probably be over-engineering things.&lt;/p&gt;</description>
                <environment>Android</environment>
            <key id="15089">NREPL-8</key>
            <summary>set stack size for Android</summary>
                <type id="4" iconUrl="http://dev.clojure.org/jira/images/icons/improvement.gif">Enhancement</type>
                                <priority id="4" iconUrl="http://dev.clojure.org/jira/images/icons/priority_minor.gif">Minor</priority>
                    <status id="6" iconUrl="http://dev.clojure.org/jira/images/icons/status_closed.gif">Closed</status>
                    <resolution id="1">Completed</resolution>
                                <assignee username="cemerick">Chas Emerick</assignee>
                                <reporter username="hank">Hank</reporter>
                        <labels>
                        <label>Android</label>
                    </labels>
                <created>Fri, 30 Dec 2011 09:05:19 -0600</created>
                <updated>Wed, 3 Oct 2012 07:03:59 -0500</updated>
                    <resolved>Wed, 3 Oct 2012 07:03:59 -0500</resolved>
                            <version>0.0.5</version>
                                <fixVersion>0.2.0-beta9</fixVersion>
                                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="27500" author="cemerick" created="Fri, 30 Dec 2011 09:14:15 -0600"  >&lt;p&gt;Noted, thank you.  I&apos;ll try to make sure a provision for this gets into the next significant release.&lt;/p&gt;

&lt;p&gt;My first inclination is to ensure that the stack size is configurable; a hardcoded size would likely be just as inappropriate in some environments as the system default.&lt;/p&gt;</comment>
                    <comment id="27789" author="cemerick" created="Tue, 21 Feb 2012 05:21:48 -0600"  >&lt;p&gt;nREPL is now using Clojure&apos;s built-in agent threadpools.  This should theoretically simplify things for you, correct?  i.e. Isn&apos;t a patched build of Clojure necessary for use on Android for this stack size issue, among other reasons?&lt;/p&gt;</comment>
                    <comment id="27796" author="hank" created="Wed, 22 Feb 2012 07:21:21 -0600"  >&lt;p&gt;The patched build is only necessary for the JVM byte code that the Clojure compiler dynamically generates to be converted to Dalvik bytecode. However adding additional android patches such as configuring the agent threadpool with a larger stack size do make sense. I&apos;m not the official Android Clojure maintainer though &amp;#8211; I guess there isn&apos;t an official one really &amp;#8211; so my opinion on this only goes so far.&lt;/p&gt;</comment>
                    <comment id="27797" author="cemerick" created="Wed, 22 Feb 2012 08:11:02 -0600"  >&lt;p&gt;Well, I think you have a solid case for expanding the scope of the android fork, or even for a change to parameterize the threadpools in Clojure itself.&lt;/p&gt;

&lt;p&gt;I&apos;m going to close this; there&apos;s really nothing to be done from within nREPL given that it doesn&apos;t maintain its own threadpool anymore.&lt;/p&gt;</comment>
                    <comment id="29035" author="cemerick" created="Tue, 24 Jul 2012 04:49:27 -0500"  >&lt;p&gt;Reopening; since the use of agents was a fool&apos;s errand, parameterizing stack size needs to happen.&lt;/p&gt;</comment>
                    <comment id="29189" author="cemerick" created="Wed, 15 Aug 2012 15:58:29 -0500"  >&lt;p&gt;Now that I look at this again, there are a number of options in nREPL to solve this.&lt;/p&gt;

&lt;p&gt;First, you can provide an &lt;tt&gt;:executor&lt;/tt&gt; argument to the &lt;tt&gt;interruptible-eval&lt;/tt&gt; middleware.  This could be any &lt;tt&gt;java.util.concurrent.Executor&lt;/tt&gt;, so you can configure it to use whatever threads you want.&lt;/p&gt;

&lt;p&gt;Second, and if you want to minimize work and retain as much of nREPL&apos;s default configuration otherwise, you can patch in your own thread pool by binding &lt;tt&gt;#&apos;clojure.tools.nrepl.middleware.interruptible-eval/configure-thread-factory&lt;/tt&gt; like so:&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;(def thread-group ...)
(def stack-size ...)

(defn android-thread-factory
  &quot;Returns a &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; ThreadFactory suitable &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; use with android. This implementation
   generates daemon threads, with names that include the session id.&quot;
  []
  (let [session-thread-counter (AtomicLong. 0)]
    (reify ThreadFactory
      (newThread [_ runnable]
        (doto (&lt;span class=&quot;code-object&quot;&gt;Thread&lt;/span&gt;. thread-group
                runnable
                (format &lt;span class=&quot;code-quote&quot;&gt;&quot;nREPL-worker-%s&quot;&lt;/span&gt; (.getAndIncrement session-thread-counter))
                stack-size)
          (.setDaemon &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;))))))

(with-bindings {#&apos;clojure.tools.nrepl.middleware.interruptible-eval/configure-thread-factory
                android-thread-factory}
  (clojure.tools.nrepl.server/start-server ...))&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The above totally untested, but I hope you get the idea.  Give it a shot, and let me know how it goes.  I&apos;m going to take off this issue&apos;s fix target for now.&lt;/p&gt;</comment>
                    <comment id="29587" author="cemerick" created="Wed, 3 Oct 2012 07:03:59 -0500"  >&lt;p&gt;I hear good things at this point about people connecting to nREPL endpoints running on Android.  Please file another issue if this or other Android-specific problems arise in the future.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                                                                            <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-global-rank">
                <customfieldname>Global Rank</customfieldname>
                <customfieldvalues>
                    
                </customfieldvalues>
            </customfield>
                                                                                                            </customfields>
    </item>
</channel>
</rss>