Skip to content

SIMD vectorization for str/bytes encode/decode operations #146555

@albertedwardson

Description

@albertedwardson

Feature or enhancement

Proposal:

Following the successful SIMD optimization of bytes.hex() in #144015, I propose implementing SIMD vectorization for common str/bytes encode/decode operations, particularly UTF-8 encoding/decoding. This could provide significant performance improvements for web applications that frequently process text data.

Web applications perform extensive encode/decode operations:

  • Content-Length headers: Computing response sizes requires encoding strings to bytes
  • Multipart responses: Encoding form data and boundaries
  • Middleware: Request/response processing often involves repeated encoding/decoding
  • JSON/HTTP processing: Converting between text and binary representations

These operations are frequently performed on the same strings multiple times, making them ideal candidates for SIMD optimization.

cc @gpshead - Would appreciate your insights on extending the SIMD pattern to encode/decode operations.

May be related: #145797

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions