Skip to content

Commit

Permalink
Move Tiered Compilation to LEIN_JVM_OPTS and document.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Mar 28, 2013
1 parent 86e6cd8 commit a42c552
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
13 changes: 7 additions & 6 deletions bin/lein
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ done

BIN_DIR="$(dirname "$SCRIPT")"

# Try to make the default more sane for :eval-in :classloader.lein
grep -E -q '^\s*:eval-in\s+:classloader\s*$' project.clj 2> /dev/null &&
LEIN_JVM_OPTS="${LEIN_JVM_OPTS:-"-Xms64m -Xmx512m"}"
export LEIN_JVM_OPTS="${LEIN_JVM_OPTS-"-XX:+TieredCompilation -XX:TieredStopAtLevel=1"}"

# When :eval-in :classloader we need more memory
grep -E -q '^\s*:eval-in\s+:classloader\s*$' project.clj 2> /dev/null && \
export LEIN_JVM_OPTS="$LEIN_JVM_OPTS -Xms64m -Xmx512m"

if [ -r "$BIN_DIR/../src/leiningen/version.clj" ]; then
# Running from source checkout
Expand Down Expand Up @@ -129,7 +131,7 @@ if [ -r "$BIN_DIR/../src/leiningen/version.clj" ]; then
fi

mkdir -p "$LEIN_DIR/target/classes"
export LEIN_JVM_OPTS="${LEIN_JVM_OPTS:-"-Xms64m -Xmx256m"} -Dclojure.compile.path=$LEIN_DIR/target/classes"
export LEIN_JVM_OPTS="$LEIN_JVM_OPTS -Dclojure.compile.path=$LEIN_DIR/target/classes"
add_path CLASSPATH "$LEIN_DIR/leiningen-core/src/" "$LEIN_DIR/leiningen-core/resources/" \
"$LEIN_DIR/test:$LEIN_DIR/target/classes" "$LEIN_DIR/src" ":$LEIN_DIR/resources"

Expand Down Expand Up @@ -285,8 +287,7 @@ else
exec sh -c "exec $(cat $TRAMPOLINE_FILE)"
else
export TRAMPOLINE_FILE
"$LEIN_JAVA_CMD" \
-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1 \
"$LEIN_JAVA_CMD" -client \
"${BOOTCLASSPATH[@]}" \
$LEIN_JVM_OPTS \
-Dfile.encoding=UTF-8 \
Expand Down
6 changes: 6 additions & 0 deletions doc/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,9 @@
around the problem would be to load a bare repl by invoking `lein
trampoline run -m clojure.main/repl`, though you may want to use
`rlwrap` on that to get proper key bindings and history.

**Q:** What does "Unrecognized VM option 'TieredStopAtLevel=1'" mean?
**A:** Old versions of the JVM do not support the directives Leiningen
uses for tiered compilation which allow the JVM to boot more
quickly. You can disable this behaviour with `export LEIN_JVM_OPTS=`
or upgrade your JVM to something more recent. (newer than b25 of Java 6)
14 changes: 10 additions & 4 deletions leiningen-core/src/leiningen/core/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@

(def deploy-repositories
(with-meta
[["clojars" {:url "https://clojars.org/repo/", :password :gpg, :username :gpg}]]
[["clojars" {:url "https://clojars.org/repo/" :password :gpg :username :gpg}]]
{:reduce add-repo}))

(defn update-if-in-map
Expand All @@ -227,8 +227,8 @@
(apply update-each m (filter (partial contains? m) ks) f args))

(defn normalize-values
"Transform values within a project or profile map to normalized values, such that
internal functions can assume that the values are already normalized."
"Transform values within a project or profile map to normalized values, such
that internal functions can assume that the values are already normalized."
[map]
(-> map
(update-if-in-map [:repositories :deploy-repositories
Expand Down Expand Up @@ -322,12 +322,18 @@
rdr false ::eof)))))
(ns ~'user))))

;; users of old JVMs will have to set LEIN_JVM_OPTS to turn off tiered
;; compilation, so if they've done that we should do the same for project JVMs
(def tiered-jvm-opts
(if (.contains (or (System/getenv "LEIN_JVM_OPTS") "") "Tiered")
["-XX:+TieredCompilation" "-XX:TieredStopAtLevel=1"] []))

(def default-profiles
"Profiles get merged into the project map. The :dev, :provided, and :user
profiles are active by default."
(atom {:default [:base :system :user :provided :dev]
:base {:resource-paths ["dev-resources"]
:jvm-opts ["-XX:+TieredCompilation" "-XX:TieredStopAtLevel=1"]
:jvm-opts tiered-jvm-opts
:test-selectors {:default (with-meta '(constantly true)
{:displace true})}
:checkout-deps-shares [:source-paths
Expand Down

0 comments on commit a42c552

Please sign in to comment.