I was curious how fast we could might be able to do some base64 encoding, so I started this based on https://github.com/aklomp/base64/tree/master/lib/arch/avx2 with some tweaks. This is a first pass, but it shows a 10x performance increase without much optimization. The thought is this might be a faster way to encode []byte values in segmentio/encoding/json
The API here matches the go standard library for the Encoding object except there are more restrictions on the encoding alphabet. The alphabet must be one of the known standard variants:
RFC 4648
RFC 4648 URI
RFC 1421
RFC 2045
RFC 2152
RFC 4880
RFC 3501
That is, arbitrary alphabets are not supported. It does panic() if the alphabet is not supported. This is in order to maintain drop-in compatibility. Though the use of custom alphabets seems like a rare enough use case that it seems reasonable to opt out of error handling.
I was curious how fast we could might be able to do some base64 encoding, so I started this based on https://github.com/aklomp/base64/tree/master/lib/arch/avx2 with some tweaks. This is a first pass, but it shows a 10x performance increase without much optimization. The thought is this might be a faster way to encode
[]byte
values insegmentio/encoding/json
The API here matches the go standard library for the
Encoding
object except there are more restrictions on the encoding alphabet. The alphabet must be one of the known standard variants:That is, arbitrary alphabets are not supported. It does
panic()
if the alphabet is not supported. This is in order to maintain drop-in compatibility. Though the use of custom alphabets seems like a rare enough use case that it seems reasonable to opt out of error handling.