Reduce token memory (lazy locations, drop whitespace trivia tokens)

Aperta
#1,829 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
38/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start by tracing the Token implementation and util.createBoundingLocation, then inspect bslint/rooibos usage of token.location and leadingTrivia for plugin compatibility. Compare the proposed lazy locations and omitted Whitespace trivia against the stated token-memory measurements. Done means reduced retained memory without breaking the getter-compatible Token API or dependent usage.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

performance

Tokens are the single biggest chunk of retained memory - ~36% of heap on Unamed OTT App after validation (and ~40% of live heap on a big client project that peaks at 6.5GB RSS).

Each token is a Token + Location + Range + 2 Position objects, ~234 bytes/token including trivia. Unamed OTT App's 3.2MB of source turns into ~196MB of tokens.

Measured on the same token data:

  • store line/col numbers on the token and build location lazily on first access: -39%
  • also drop Whitespace trivia tokens (text is already in leadingWhitespace, and they're ~35% of all token objects): -53%

Less allocation should also help GC, which is ~14-15% of validation CPU.

Same idea could apply to AST node locations from util.createBoundingLocation (~5% of heap) - compute from the first/last token on demand.

Token is part of the plugin API though, so needs a getter-compatible shape and a check against bslint/rooibos usage of token.location and leadingTrivia.

Lingua principale
TypeScript
Stelle
212
Fork
72
Merge medio
3g 3h
PR unite (30g)
63

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rokucommunity/brighterscript

Tutte le issue di rokucommunity/brighterscript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.