You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have looked for existing issues (including closed) about this
Feature Request
Motivation
I'm working on a Fediverse server implementation, using axum as the web framework. Fediverse servers receive thousands of request every second, even for small instances, like the one I run, so performance is important. Because ActivityPub uses copious amounts of JSON, I figure it's best to use a high-performance JSON parser, like simd-json. However, simd-json's simd_json::from_slice takes a mutable byte slice rather than an immutable one, so I can't use Bytes for that.
This is just one particular usecase, but I'm confident there are other performance-critical scenarios where you'd want a BytesMut value instead of a Bytes value.
Proposal
In axum-core, add the impl, using the existing Bytes impl as a starting point.
Alternatives
For my usecase, I could theoretically turn the Bytes value into a Vec<u8> and then into a BytesMut, but that would likely involve expensive copy operations that would nullify the performance gains from using simd-json.
The text was updated successfully, but these errors were encountered:
For my usecase, I could theoretically turn the Bytes value into a Vec and then into a BytesMut,
I suppose that’s what axum would have to do as well. Since the body is an async stream you can’t get a mutable reference to the data until you’ve buffered the whole thing. axum doesn’t store the body as Bytes internally or anything.
I'm pretty sure an efficient impl is possible, easy even. I'm surprised the BodyExt::collect thing we use now isn't implemented in terms of collecting to BytesMut + .freeze(), I suppose it is too generic.
Feature Request
Motivation
I'm working on a Fediverse server implementation, using axum as the web framework. Fediverse servers receive thousands of request every second, even for small instances, like the one I run, so performance is important. Because ActivityPub uses copious amounts of JSON, I figure it's best to use a high-performance JSON parser, like
simd-json
. However,simd-json
'ssimd_json::from_slice
takes a mutable byte slice rather than an immutable one, so I can't useBytes
for that.This is just one particular usecase, but I'm confident there are other performance-critical scenarios where you'd want a
BytesMut
value instead of aBytes
value.Proposal
In axum-core, add the impl, using the existing
Bytes
impl as a starting point.Alternatives
For my usecase, I could theoretically turn the
Bytes
value into aVec<u8>
and then into aBytesMut
, but that would likely involve expensive copy operations that would nullify the performance gains from usingsimd-json
.The text was updated successfully, but these errors were encountered: