Skip to content

buffer: improve `atob` performance

Rodrigo Muino Tomonari requested to merge github/fork/anonrig/deps/simdutf into main

The code is 99% written by @lemire, I just glued them all together.

This pull-request introduces a much faster atob implementation, and solves solves some security aspects of the previous implementation. Usage of atob is still discouraged.

Refs: https://github.com/nodejs/node/pull/51670

Benchmarks

                                          confidence improvement accuracy (*)    (**)   (***)
buffers/buffer-atob.js n=1000000 size=16         ***    457.77 %       ±3.28%  ±4.42%  ±5.86%
buffers/buffer-atob.js n=1000000 size=256        ***   2505.57 %      ±15.69% ±21.14% ±28.07%
buffers/buffer-atob.js n=1000000 size=64         ***   1213.33 %       ±3.98%  ±5.36%  ±7.11%

Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 3 comparisons, you can thus expect the following amount of false-positive results:
  0.15 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.03 false positives, when considering a   1% risk acceptance (**, ***),
  0.00 false positives, when considering a 0.1% risk acceptance (***)

Merge request reports

Loading