Fork me on GitHub
#ring
<
2018-05-28
>
ikitommi06:05:03

I think it would be a good idea if ring (the implementation) would support & enforce returning byte-array:s.

ikitommi06:05:49

It seems to be the fastest way to return things out from memory, e.g. Clojure data -> JSON.

ikitommi06:05:34

NIO-servers can send it as ByteBuffer and non-NIO can write it directly to a ByteArrayOutputStream with .write.

ikitommi06:05:13

… and Jackson (and Jsonista) has optimized path for producing it, no intemediate Strings or Streams.

ikitommi06:05:59

what do you think @weavejester? I think there was a catch on implementing Protocols for primitive-arrays. Seem to work thou.

weavejester13:05:19

ByteBuffers are not supported by all NIO servers. The problem with NIO in particular is that many Java NIO servers predate Java’s own NIO classes, so for instance Netty uses its own system (last I looked).

weavejester13:05:00

If it’s feasible to extend a protocol to a byte array without issue, then I don’t see any reason not to add this as a body return type.

ikitommi15:05:17

Oh, didn't know about the Netty non-NIO internals. Anyway, both Aleph & Immutant(alpha) serve over 1M req/sec in the latest TechEmpower JSON test, both with byte-arrays.

ikitommi15:05:48

I'll check if it works in all cases and do a PR.