emilypi / emilypi/base64

Performance Improvements

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
Haskell
Stars
38
Forks
13
PR merge metrics
No merged PRs in 30d

Description

This issue is a catch-all for performance improvements, for which help is wanted. I can list some off the top of my head:

- [x] The `Text` conversions via `decodeUtf8` in `encodeBase64` is unnecessary. We've already decoded to an alphabet we know is safe for decoding, so the conversion can be streamlined.

- [x] Inline the lookup tables as static arrays so we can stop building them with every encode/decode. **(Closed in #9 - not faster than pure haskell)**

- [x] The inner loop can be optimized in terms of Aklomp's algorithm. We should be able to read off hunks of `Word32` or `Word64` from the input, convert to big endian, and do things with single-read, 4 bitshift instructions per round. **(Done as of #8)**

- [x] Inner loops can pack words (performance pending) and do a single write in the unpadded case as a large word to the output pointer, eliminating unnecessary writes per iteration. **(Done as of #10)**

- [ ] `Data.ByteString.Short`-optimized inner-loops. See: https://github.com/emilypi/Base16/blob/master/src/Data/ByteString/Base16/Internal/W16/ShortLoop.hs
- [ ] SSE/AVX2 vectorization is possible via Aklomp's library. I have no experience with this. Help please!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.