Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encoding/hex: implement Decode with a lookup table
Implement hex decode using a 256 byte lookup table instead of branching logic. In happy flow, uses 3x 64 byte (or 5x 32 byte) cache lines. name old time/op new time/op delta Decode/256-64 223ns ± 3% 135ns ± 2% -39.64% (p=0.000 n=8+8) Decode/1024-64 872ns ± 2% 512ns ± 2% -41.25% (p=0.000 n=8+8) Decode/4096-64 3.43µs ± 1% 2.01µs ± 2% -41.31% (p=0.001 n=7+7) Decode/16384-64 13.9µs ± 1% 8.0µs ± 1% -42.69% (p=0.000 n=8+7) name old speed new speed delta Decode/256-64 1.15GB/s ± 3% 1.90GB/s ± 2% +65.66% (p=0.000 n=8+8) Decode/1024-64 1.17GB/s ± 2% 2.00GB/s ± 2% +70.22% (p=0.000 n=8+8) Decode/4096-64 1.20GB/s ± 1% 2.04GB/s ± 2% +70.39% (p=0.001 n=7+7) Decode/16384-64 1.18GB/s ± 1% 2.06GB/s ± 1% +74.49% (p=0.000 n=8+7) Also reduces amd64 object size by 766 bytes, despite the extra RODATA due to removal of `fromHexChar()` and duplicated inlined versions of it and simplification of `Decode()`. Change-Id: I0988c7a30562ec154eff11db6e27954e0ce2b611 GitHub-Last-Rev: 6481801 GitHub-Pull-Request: #51432 Reviewed-on: https://go-review.googlesource.com/c/go/+/390037 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org>
- Loading branch information