jlfwong/speedscope

Optimize fallback path when TextDecoder is not available

Open

#189 ouverte le 8 nov. 2018

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)TypeScript (181 forks)batch import
good first issuehelp wanted

Métriques du dépôt

Stars
 (4 040 stars)
Métriques de merge PR
 (Merge moyen 1j 17h) (1 PR mergée en 30 j)

Description

In https://github.com/jlfwong/speedscope/pull/188, I introduced TextDecoder as a way of avoiding performance issues with building up a huge string slowly. There are ways to make the fallback path faster and use less memory as well:

From @evanw:

The problem is that JavaScript JITs such as V8 optimize repeated string appends by building up a linked list in memory and only constructing the full string when the string is first used. So you probably want to periodically flatten the string in your loop to avoid running out of memory.

For future reference: one way to get Chrome to evaluate the string is to do str[0];. That doesn't appear to do anything but actually has the side effect of evaluating the string.

This fallback path is probably only used in Edge: https://caniuse.com/#feat=textencoder

Guide contributeur