ring

ikitommi 2018-05-28T06:32:03.000163Z

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

ikitommi 2018-05-28T06:32:49.000228Z

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

ikitommi 2018-05-28T06:33:34.000242Z

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

ikitommi 2018-05-28T06:34:13.000089Z

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

ikitommi 2018-05-28T06:34:59.000089Z

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

ikitommi 2018-05-28T06:38:07.000174Z

related: https://github.com/metosin/muuntaja/pull/64

2018-05-28T13:44:19.000033Z

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).

2018-05-28T13:45:00.000226Z

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.

ikitommi 2018-05-28T15:46:17.000025Z

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.

ikitommi 2018-05-28T15:46:48.000012Z

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