Browse Source

Fast aleph (#3619)

* Update deps

* tuned

* JVM opts

* Revert how response maps are generated

* aleph 0.4.5-alpha6

* Update README
Tommi Reiman 7 years ago
parent
commit
9010f461a8

+ 3 - 3
frameworks/Clojure/aleph/README.md

@@ -10,9 +10,9 @@ This is the [Aleph](https://github.com/ztellman/aleph) portion of a [benchmarkin
 The dependencies are documented in [project.clj](hello/project.clj),
 The dependencies are documented in [project.clj](hello/project.clj),
 but the main ones are:
 but the main ones are:
 
 
-* [Aleph 0.4.1-beta2](https://github.com/ztellman/aleph)
-* [Clojure 1.8.0](http://clojure.org/)
-* [Cheshire 5.5.0](https://github.com/dakrone/cheshire), which in turn uses [Jackson](http://jackson.codehaus.org/)
+* [Aleph 0.4.5-alpha6](https://github.com/ztellman/aleph)
+* [Clojure 1.9.0](http://clojure.org/)
+* [metosin/jsonista 0.1.1](https://github.com/metosin/jsonista), which in turn uses [Jackson](http://jackson.codehaus.org/)
 
 
 ## Test URLs
 ## Test URLs
 ### JSON Encoding Test
 ### JSON Encoding Test

+ 1 - 1
frameworks/Clojure/aleph/aleph.dockerfile

@@ -3,4 +3,4 @@ WORKDIR /aleph
 COPY src src
 COPY src src
 COPY project.clj project.clj
 COPY project.clj project.clj
 RUN lein uberjar
 RUN lein uberjar
-CMD ["java", "-server", "-Xmx2g", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=10", "-jar", "target/hello-aleph-standalone.jar"]
+CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-jar", "target/hello-aleph-standalone.jar"]

+ 5 - 5
frameworks/Clojure/aleph/project.clj

@@ -1,10 +1,10 @@
 (defproject hello "aleph"
 (defproject hello "aleph"
   :description "JSON/plaintext tests"
   :description "JSON/plaintext tests"
-  :dependencies [[org.clojure/clojure "1.8.0"]
+  :dependencies [[org.clojure/clojure "1.9.0"]
                  [clj-tuple "0.2.2"]
                  [clj-tuple "0.2.2"]
-                 [org.clojure/tools.cli "0.3.3"]
-                 [aleph "0.4.1-beta2"]
-                 [javax.xml.bind/jaxb-api "2.2.12"]
-                 [cheshire "5.5.0"]]
+                 [org.clojure/tools.cli "0.3.6"]
+                 [aleph "0.4.5-alpha6"]
+                 [javax.xml.bind/jaxb-api "2.3.0"]
+                 [metosin/jsonista "0.1.1"]]
   :main hello.handler
   :main hello.handler
   :aot :all)
   :aot :all)

+ 8 - 7
frameworks/Clojure/aleph/src/hello/handler.clj

@@ -3,7 +3,7 @@
     [byte-streams :as bs]
     [byte-streams :as bs]
     [clojure.tools.cli :as cli]
     [clojure.tools.cli :as cli]
     [aleph.http :as http]
     [aleph.http :as http]
-    [cheshire.core :as json]
+    [jsonista.core :as json]
     [clj-tuple :as t])
     [clj-tuple :as t])
   (:gen-class))
   (:gen-class))
 
 
@@ -18,12 +18,13 @@
     :status 200
     :status 200
     :headers (t/hash-map "content-type" "application/json")))
     :headers (t/hash-map "content-type" "application/json")))
 
 
-(defn handler [{:keys [uri] :as req}]
-  (cond
-    (= "/plaintext" uri) plaintext-response
-    (= "/json" uri) (assoc json-response
-                      :body (json/encode (t/hash-map :message "Hello, World!")))
-    :else {:status 404}))
+(defn handler [req]
+  (let [uri (:uri req)]
+    (cond
+      (.equals "/plaintext" uri) plaintext-response
+      (.equals "/json" uri) (assoc json-response
+                              :body (json/write-value-as-bytes (t/hash-map :message "Hello, World!")))
+      :else {:status 404})))
 
 
 ;;;
 ;;;