ring

ikitommi 2019-05-07T05:17:11.079400Z

could the next version of Ring be based on protocols? e.g. Request and Response protocols. Maps could implement this, so one could use it as before, but it would enable faster processing in libraries: 1) request comes in (via Immutant), does a zero-copy request proxy, implementing the ring protocols (now: own custom protocols for this) + map interfaces so it can be used as a map 2) when a request needs to be inspected in a routing / middleware / web library - it coud use the protocols like (ring2.core/get-uri request) & (ring2.core/get-request-method request), which would basically translate to direct java method calls to Undertow Java Request implementation => much faster, no need to realize the full request maps if they are not used 3) apps could choose to use the map-syntax or the protocol-syntax

mpenet 2019-05-07T10:10:25.080100Z

You can turn the problem around and use a request/response ds that "behaves" like a map but only realizes (and potentially caches) the values as requested

mpenet 2019-05-07T10:10:50.080400Z

potemkin had something like that

mpenet 2019-05-07T10:12:26.081100Z

seems to be what aleph is doing on some parts too: https://github.com/ztellman/aleph/search?q=def-derived-map&unscoped_q=def-derived-map

ikitommi 2019-05-07T10:36:51.088Z

Copied that to my immutant(-nio) fork too (https://github.com/ikitommi/immutant/blob/master/web/src/immutant/web/internal/undertow.clj#L226-L244). I think it’s a good approach, but there is still a extra hop (and internal cache) between the caller and the data. Could bench that out, but an exposed protocol would be truely zero-fat.

ikitommi 2019-05-07T10:38:58.089300Z

but, true, it would be less intrusive to do that behind the scenes (like those two web servers do it today)

mpenet 2019-05-07T10:39:13.089700Z

should be quite close, it's just a method call that calls another method under the hood

mpenet 2019-05-07T10:39:33.090300Z

I guess the jvm might do some magic to remove the overhead after a while

ikitommi 2019-05-07T10:40:01.091100Z

could be, I did some benching while ago, could rerun.

mpenet 2019-05-07T10:40:14.091700Z

(I am not super familiar with the internals of derived-map, but you could simplify it to the strict minimum and tune it to that use case)

ikitommi 2019-05-07T10:50:31.093Z

I’ll run some numbers and get back. thanks for the thoughts