The future of rendering #7389
rossabaker
started this conversation in
Ideas
Replies: 1 comment
-
A bit of noodling with bidirectional programming with monadic profunctors based on Li-yao Xia's paper. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Coming out of #7386, a question is where should the codecs live? This discussion focuses on rendering.
http4s was primarily focused on HTTP/1 when we forked akka-http. HTTP/1 codecs to strings are deeply ingrained in the core: most types have a cats-parse parser, and extend
Renderable
to participate in a serialization framework whose main implementation is a String. There's not a particular reason HTTP/1 should have primacy in 2024. Packaging HTTP codecs per version makes some sense.Ember and Blaze both render their HTTP/1 initial line and headers to a
StringBuilder
, converting that to aString
, and encoding in one pass to anArray[Byte]
. That's a lot of wasteful copying, not to mention the fact that many of the components (likeHTTP/1.0
) are internable and could cache their byte arrays. But: it's also faster in practice than the seemingly appropriate and incremental CharsetEncoder!I can beat Ember by about 5% encoding straight to
ByteBuffer
, with some extra effort. I do about 60% worse usingByteVector
(even with buffering) orChunk
concatenation.I'm not sure how much backends can share codecs. There's nuance that would require reengineering to make Blaze and Ember share more. Netty might join the party, but currently operates more like servlets in translating the model. If it did join the party, it uses a different byte buffering abstraction. But the mechanics of "what bytes represent this HTTP version in HTTP/1?" are the same, so burying it fully in Ember seems dumb.
I think this is what akka-http tried to accomplish with its rendering framework: "the same bytes, serialized lots of ways". But we abandoned binary in each of the "native" backends even though it's all TCP at the fringe.
We should evaluate:
Beta Was this translation helpful? Give feedback.
All reactions