Totodore / socketioxide

A socket.io server implementation in Rust that integrates with the Tower ecosystem and the Tokio stack.
https://docs.rs/socketioxide
MIT License
1.13k stars 49 forks source link

feat(engineio): add a `Str` type for Message packet #310

Closed Totodore closed 2 months ago

Totodore commented 2 months ago

Motivation

Currently the Message packet variant is backed by a String. This leads to a useless data clone when slicing to remove the first byte (the engineio packet type).

Solution

The Str type is backed by a Bytes and therefore can be sliced into any number of sub-Bytes.

github-actions[bot] commented 2 months ago

🐰Bencher

ReportSun, April 21, 2024 at 20:47:25 UTC
ProjectSocketioxide
Branchzero-copy-bytes-take2
Testbedubuntu-latest
BenchmarkLatencyLatency Results
nanoseconds (ns)
engineio_packet/decode/Decode packet binary b64➖ (view plot)86.264
engineio_packet/decode/Decode packet message➖ (view plot)46.464
engineio_packet/decode/Decode packet noop➖ (view plot)36.409
engineio_packet/decode/Decode packet ping/pong➖ (view plot)31.365
engineio_packet/decode/Decode packet ping/pong upgrade➖ (view plot)35.333
engineio_packet/encode/Encode packet binary b64➖ (view plot)55.198
engineio_packet/encode/Encode packet message➖ (view plot)30.241
engineio_packet/encode/Encode packet noop➖ (view plot)30.119
engineio_packet/encode/Encode packet open➖ (view plot)292.780
engineio_packet/encode/Encode packet ping/pong➖ (view plot)29.663
engineio_packet/encode/Encode packet ping/pong upgrade➖ (view plot)29.959
extensions/concurrent_get➖ (view plot)25.880
extensions/concurrent_get_inserts➖ (view plot)31.057
extensions/concurrent_inserts➖ (view plot)24.175
socketio_packet/decode/Decode packet ack on /➖ (view plot)276.560
socketio_packet/decode/Decode packet ack on /custom_nsp➖ (view plot)292.440
socketio_packet/decode/Decode packet binary ack (b64) on /➖ (view plot)511.410
socketio_packet/decode/Decode packet binary ack (b64) on /custom_nsp➖ (view plot)536.560
socketio_packet/decode/Decode packet binary event (b64) on /➖ (view plot)599.700
socketio_packet/decode/Decode packet binary event (b64) on /custom_nsp➖ (view plot)619.570
socketio_packet/decode/Decode packet connect on /➖ (view plot)62.290
socketio_packet/decode/Decode packet connect on /custom_nsp➖ (view plot)76.708
socketio_packet/decode/Decode packet event on /➖ (view plot)350.500
socketio_packet/decode/Decode packet event on /custom_nsp➖ (view plot)368.720
socketio_packet/decode/Decode packet event with ack on /➖ (view plot)349.560
socketio_packet/decode/Decode packet event with ack on /custom_nsp➖ (view plot)368.280
socketio_packet/encode/Encode packet ack on /➖ (view plot)118.160
socketio_packet/encode/Encode packet ack on /custom_nsp➖ (view plot)121.120
socketio_packet/encode/Encode packet binary ack (b64) on /➖ (view plot)313.160
socketio_packet/encode/Encode packet binary ack (b64) on /custom_nsp➖ (view plot)317.860
socketio_packet/encode/Encode packet binary event (b64) on /➖ (view plot)399.640
socketio_packet/encode/Encode packet binary event (b64) on /custom_nsp➖ (view plot)418.910
socketio_packet/encode/Encode packet connect on /➖ (view plot)53.156
socketio_packet/encode/Encode packet connect on /custom_nsp➖ (view plot)55.337
socketio_packet/encode/Encode packet event on /➖ (view plot)122.620
socketio_packet/encode/Encode packet event on /custom_nsp➖ (view plot)126.530
socketio_packet/encode/Encode packet event with ack on /➖ (view plot)122.550
socketio_packet/encode/Encode packet event with ack on /custom_nsp➖ (view plot)126.140

Bencher - Continuous Benchmarking
View Public Perf Page
Docs | Repo | Chat | Help