Open Bug 2003305 Opened 3 months ago Updated 3 months ago

fromBase64 is very slow

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

Performance Impact medium

People

(Reporter: denispal, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Go to https://simdutf.github.io/browserbase64/ and run the benchmark.

Firefox:
~3083.30 MiB/s

Chrome:
~7060.66 MiB/s

Safari:
~11336.78 MiB/s

We were even worse before, but bug 1994067 and bug 1995626 improved performance by about 10x. However, we are 2-3x behind.

Profile: https://share.firefox.dev/4ajW3kw

I see two things:

  1. The CPU work of decoding and storing the bytes is where most of the time (78%) is spent.
  2. We decode into a temporary buffer and do a copy rather than adopting the buffer into the typed array.

The copy seems worth avoiding. TypedArray::fromLength also has the cost of zeroing the allocated buffer, which is unnecessary since we're going to overwrite all of it. Edit: Ah, André had already filed bug 1996197 about the copy, nice.

Depends on: 1996197
Blocks: sm-js-perf
Severity: -- → N/A
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.