ninjasource / embedded-websocket

A rust websocket library for embedded systems (no_std)
Apache License 2.0
98 stars 28 forks source link

Add base64 simd support #12

Open stevefan1999-personal opened 2 years ago

stevefan1999-personal commented 2 years ago

This will require nightly, so it is disabled by default

ninjasource commented 2 years ago

Hi, thanks for your PR. Can you please let me know what the motivation for adding base64 simd support is? This crate is primarily for no_std use and I see that you have put if behind feature flags which is great but I'd like to know why base64 encoding was slowing things down so much to warrant this added complexity. Did you benchmark it? Base64 encoding is only done when initially setting up the connection. I'm asking because I purposefully chose not to have many dependencies because networking stuff should be easily auditable. Adding dependencies adds surface area for supply chain attack.

stevefan1999-personal commented 2 years ago

@ninjasource using SIMD means smaller code size thanks to instruction level vectorization and this saves a lot of precious space on constrained microcontrollers such as Cortex-M4 where they do have a SIMD execution unit.

Also supply chain attack is very hard for Rust if you properly pin dependencies since version policy of Rust crates are immutable (implying idempotency between each build). Just check well before upgrading your code.