Fork me on GitHub
#reitit
<
2017-12-17
>
ikitommi15:12:38

@yogthos sure will! with this pace, pushing out feature per week, should be stable by end of year. I want to support both clj & cljs right from start, so need to port the ring-swagger for cljc too. Als, reitit-http will be pedestal/interceptors, reitit-ring ring/middleware. I guess Luminus stays with the Ring-stack? Both modules will have the same features.

yogthos15:12:57

this actually opens up the possibility of adding a pedestal profile in luminus

ikitommi18:12:15

One thing we chatted earlier was ability to make the middleware chains lazy: one could modify the chain at runtime (like the interceptor queueing). Here are some benchmarks, executing a chain of 10 no-op middleware / interceptor:

; Middleware (static chain) => 5µs
; Middleware (dynamic chain) => 60µs

; Interceptor (static queue) => 20µs
; Interceptor (context queues) => 30µs
; Pedestal (context queues) => 79µs

ikitommi18:12:04

By default, the middleware chain is really fast, smal functions to the stack. Its an order of magnitude faster than pedestal chain (all logging turned off).

ikitommi18:12:36

making the middleware chain modifiable at runtime makes it x10 slower. And in my test there was no initialization, if there would be mw argument parsing etc. it would be even slower.

ikitommi19:12:35

Did few tests on how to create a fast interceptor runner, simplests runners (written in java) could be something like x3 slower than the mw-version. To support generic async (manifold, core.async, promesa) has some impact.

ikitommi19:12:01

but: the mw-chain is always the fastest, interceptor-chain is more handy with async.

ikitommi19:12:25

Trying to get the Pedestal people interested in creating a “Interceptor Spec” (like the Ring spec is today) that could be used with different interceptor libs. Currently, many version of the original, bit different and thus incompatible.

ikitommi19:12:24

oh, that was 100-long chain. not from real life with chain of 10:

; Middleware (map, static chain)     =>  960ns
; Middleware (record, static chain)  =>  380ns
; Middleware (dynamic chain)         => 6600ns

; Interceptor (static queue)         => 2000ns
; Interceptor (context queues)       => 3000ns
; Pedestal (context queues)          => 8800ns

ikitommi19:12:34

mw:

(defn middleware [handler value]
  (fn [request]
    (let [values (or (:values request) [])]
      (handler (assoc request :values (conj values value))))))

ikitommi19:12:28

interceptor (before IntoInterceptor):

(defn interceptor [value]
  (fn [context]
    (let [values (or (:values context) [])]
      (assoc context :values (conj values value)))))