golang/go

x/text/unicode/norm: reduce init-time memory usage

Open

#26 752 ouverte le 1 août 2018

Voir sur GitHub
 (7 commentaires) (0 réactions) (0 assignés)Go (19 008 forks)batch import
NeedsFixPerformancehelp wanted

Métriques du dépôt

Stars
 (133 883 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

The golang.org/x/text/unicode/norm package allocs 21.47kB in its init function, regardless of whether the package is ever used.

We should do it lazily, as done in e.g. https://go-review.googlesource.com/c/net/+/127275 and https://go-review.googlesource.com/c/go/+/127075

This would help people who explicitly import it (or import it via golang.org/x/net/http2), as then the std-vendored copy would not need to also allocate the 20KB.

Perhaps some of those tables should be const strings, too, so the linker can put it in read-only sections. Then we can slice into it at runtime to get integers out.

/cc @mpvl

Guide contributeur