microsoft / microsoft/TypeScript

Use a data object instead of function closures for oldPrograms

Aperta
#37,793 1 commento 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

In Discussion Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

Search Terms

structured clone algorithm, oldProgram, function closure

Suggestion

Create some transformer that transforms a Program to an OldProgram, which, instead of using function closures, would store the data, necessary for "rehydrating" a program, directly on the OldProgram object.
The createProgram function would then take a Program|OldProgram as the parameter for oldProgram.
The OldProgram object should be compatible with the structured clone algorithm, which would involve creating similar "serialized++" versions of all of the transitive objects contained in the data of OldProgram

Use Cases & Motivation

When caching a Program for use in a later compiler step, it contains many functions not consumed when taking in an oldProgram, these functions are needlessly holding variables in their closure/memory.
By trimming the methods down to only those used, the memory footprint is reduced, but they still have a memory cost of about 15MB for most of our projects (this number calcuated by observing ~2300MB freed after deleting 150 Programs from a cache). In our case this becomes ~22GB for all our projects. It would be nice to create a more lightweight version of these that can still be efficiently rehydrated for quick compiler actions.
This could also allow users in a specific use case to trim down the data more than is prudent to allow them to cache all of the Programs.
As an added bonus, if the OldProgram type could be made compatible with the structured clone algorithm, then it would be much easier to share a single, much larger, cache between a dozen-or-so compiler hosts.

As noted in #37701, compile times are slow when not able to reuse an oldProgram, this is aimed at helping users to be able to reuse an oldProgram more often.

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Non vengono indicati file o test. Inizia tracciando i punti di ingresso oldProgram e createProgram, quindi leggi l’issue #37701 e i requisiti di structured clone descritti qui. Il lavoro è completato quando i dati memorizzati nella cache basati su closure vengono sostituiti da un OldProgram reidratabile, preservando il riutilizzo e riducendone l’occupazione di memoria.

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

Valutazione

Stack tecnologico
typescript
Ambito
compilers, performance
Tipo di issue
Refactoring
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.