Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frameworks/aleph/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM clojure:temurin-21-lein AS builder
FROM clojure:temurin-26-lein-trixie AS builder
WORKDIR /app
COPY project.clj ./
COPY resources ./resources
RUN lein deps
COPY src ./src
RUN lein with-profile uberjar uberjar

FROM eclipse-temurin:25-jre
FROM eclipse-temurin:26-jre
RUN mkdir -p /data/static
WORKDIR /app
COPY --from=builder /app/target/aleph-bench-0.1.0-standalone.jar /app/app.jar
Expand Down
4 changes: 3 additions & 1 deletion frameworks/aleph/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"noisy",
"short-lived",
"mixed",
"json-tls",
"api-4",
"api-16",
"async-db",
"sync-db",
"static",
"tcp-frag"
"tcp-frag",
"crud"
]
}
6 changes: 3 additions & 3 deletions frameworks/aleph/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
io.netty/netty-transport-native-kqueue
io.netty/netty-transport-native-unix-common]]
[io.netty/netty-all "4.2.12.Final"]
[org.clojars.jj/tassu "1.0.3"]
[org.clojars.jj/tassu "1.0.4"]
[org.clojars.jj/boa-sql "1.0.10"]
[org.clojars.jj/async-boa-sql "1.0.10"]
[org.clojars.jj/next-jdbc-adapter "1.0.10"]
[org.clojars.jj/vertx-pg-client-async-boa-adapter "1.0.1"]
[org.xerial/sqlite-jdbc "3.49.1.0"]
[metosin/jsonista "1.0.0"]
[com.github.seancorfield/next.jdbc "1.3.1093"]]

[org.clojure/core.cache "1.2.263"]]

:main ^:skip-aot aleph-bench.core

Expand Down
1 change: 1 addition & 0 deletions frameworks/aleph/resources/sql/crud-create
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO items (id, name, category, price, quantity, active, tags, rating_score, rating_count) VALUES (:id, :name, :category, :price, :quantity, true, '["bench"]', 0, 0) ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name, price = EXCLUDED.price, quantity = EXCLUDED.quantity RETURNING id
1 change: 1 addition & 0 deletions frameworks/aleph/resources/sql/crud-list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT id, name, category, price, quantity, active, tags, rating_score, rating_count FROM items WHERE category = :category ORDER BY id LIMIT :limit OFFSET :offset
1 change: 1 addition & 0 deletions frameworks/aleph/resources/sql/crud-read
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT id, name, category, price, quantity, active, tags, rating_score, rating_count FROM items WHERE id = :id LIMIT 1
1 change: 1 addition & 0 deletions frameworks/aleph/resources/sql/crud-update
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE items SET name = :name, price = :price, quantity = :quantity WHERE id = :id
395 changes: 255 additions & 140 deletions frameworks/aleph/src/aleph_bench/core.clj

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion frameworks/ring-http-exchange/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
[org.clojars.jj/tassu "1.0.4"]
[org.clojars.jj/boa-sql "1.0.10"]
[org.clojars.jj/next-jdbc-adapter "1.0.10"]
[org.xerial/sqlite-jdbc "3.49.1.0"]
[org.postgresql/postgresql "42.7.5"]
[metosin/jsonista "1.0.0"]
[com.zaxxer/HikariCP "6.2.1"]
Expand Down
33 changes: 1 addition & 32 deletions frameworks/ring-http-exchange/src/ring/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[jj.sql.boa.query.next-jdbc :refer [->NextJdbcAdapter]]
[jj.tassu :refer [GET POST PUT route]]
[jsonista.core :as json]
[next.jdbc :as jdbc]
[ring-http-exchange.core :as server]
[ring-http-exchange.ssl :as ssl])
(:import (com.zaxxer.hikari HikariConfig HikariDataSource)
Expand All @@ -32,7 +31,6 @@
(def ^:private ^:const dot ".")
(def ^:private ^:const not-found-body "Not found")
(def ^:private ^:const dataset-path "/data/dataset.json")
(def ^:private ^:const db-path "/data/benchmark.db")
(def ^:private ^:const static-dir "/data/static")
(def ^:private ^:const param-min "min")
(def ^:private ^:const param-max "max")
Expand All @@ -50,7 +48,6 @@
(def ^:private json-gzip-headers {hdr-ct ct-json hdr-ce enc-gzip hdr-server server-name})
(def ^:private text-headers {hdr-ct ct-text hdr-server server-name})

(def ^:private sqlite-query (boa/build-query (->NextJdbcAdapter) "sql/db-query"))
(def ^:private pg-query (boa/build-query (->NextJdbcAdapter) "sql/pg-query"))
(def ^:private crud-list-query (boa/build-query (->NextJdbcAdapter) "sql/crud-list"))
(def ^:private crud-read-query (boa/build-query (->NextJdbcAdapter) "sql/crud-read"))
Expand Down Expand Up @@ -136,16 +133,6 @@
ext (if (>= dot-index 0) (subs name dot-index) "")]
(get extension-map ext ct-octet)))

(defn- transform-sqlite-row [row]
{:id (:id row)
:name (:name row)
:category (:category row)
:price (:price row)
:quantity (:quantity row)
:active (== 1 (long (:active row)))
:tags (json/read-value (:tags row) json/keyword-keys-object-mapper)
:rating {:score (:rating_score row) :count (:rating_count row)}})

(defn- transform-pg-row [row]
{:id (:id row)
:name (:name row)
Expand Down Expand Up @@ -196,10 +183,6 @@
(println (str "Failed to start server on port " port
": " (.getMessage e))))))))

(defn- init-sqlite []
(when (.exists (io/file db-path))
(jdbc/get-datasource {:dbtype "sqlite" :dbname db-path :read-only true})))

(defn- init-postgres []
(when-let [url (System/getenv "DATABASE_URL")]
(try
Expand Down Expand Up @@ -242,22 +225,10 @@
(with-open [^InputStream in (:body req)]
(text-response (.transferTo in (OutputStream/nullOutputStream)))))

(defn- query-sqlite-items [ds params]
(try (mapv transform-sqlite-row (sqlite-query ds params))
(catch Exception _ [])))

(defn- query-pg-items [ds params]
(try (mapv transform-pg-row (pg-query ds params))
(catch Exception _ [])))

(defn- handle-sqlite [ds req]
(let [params (parse-qs (:query-string req))
min-p (safe-parse-double (get params param-min) 10.0)
max-p (safe-parse-double (get params param-max) 50.0)
limit (safe-parse-long (get params param-limit) 50)
items (query-sqlite-items ds {:min min-p :max max-p :limit limit})]
(json-response {:items items :count (clojure.core/count items)})))

(defn- handle-pg [ds req]
(let [params (parse-qs (:query-string req))
min-p (safe-parse-double (get params param-min) 10.0)
Expand Down Expand Up @@ -353,13 +324,12 @@
:body f}
{:status 404 :body not-found-body})))

(defn- build-handler [{:keys [dataset sqlite-ds pg-ds]}]
(defn- build-handler [{:keys [dataset pg-ds]}]
(route
{"/baseline11" [(GET handle-baseline-get)
(POST handle-baseline-post)]
"/json/:count" [(GET (fn [req] (handle-json dataset req)))]
"/upload" [(POST handle-upload)]
"/db" [(GET (fn [req] (handle-sqlite sqlite-ds req)))]
"/async-db" [(GET (fn [req] (handle-pg pg-ds req)))]
"/crud/items" [(GET (fn [req] (handle-crud-list pg-ds req)))
(POST (fn [req] (handle-crud-create pg-ds req)))]
Expand All @@ -371,7 +341,6 @@
(defn -main [& _]
(let [dataset (load-json (or (System/getenv "DATASET_PATH") dataset-path))
handler (build-handler {:dataset dataset
:sqlite-ds (init-sqlite)
:pg-ds (init-postgres)})]
(start-server! handler plain-port)
(start-server! handler tls-port (load-ssl-context))))
Loading