Codespine version 2: support many programming languages with tree-sitter and pprof

Aperta
#234 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript

Direzione di ricerca

Start by reading docs/GRAPHIFY_COMPARISON.md and research the profiling tools, output formats, pprof support, converters, and tree-sitter call resolution for Go, Python, Java, Rust, and Node.js. Post the findings as a table in a comment on this issue, including whether C and C++ should be added to the first language list. Done means the table addresses all five research questions for each language.

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

Descrizione

enhancement vision

Goal

Build Codespine version 2: the same product as Codespine today, but for many programming languages instead of TypeScript only. Today Codespine reads TypeScript with ts-morph and reads runtime cost from V8 CPU profiles. Version 2 replaces both inputs with language-neutral ones.

Proposed approach

  • Static analysis: use tree-sitter, a parser library that supports many languages, in place of ts-morph. Graphify uses tree-sitter for the same purpose (see docs/GRAPHIFY_COMPARISON.md).
  • Runtime profiling: use the pprof profile file format, which many language runtimes and profiling tools can write, in place of V8 CPU profiles. Converters exist for profile formats that are not pprof.

Languages to support first

  • Go
  • Python
  • Java
  • Rust
  • Node.js (already supported through V8 CPU profiles)

C and C++ do not appear in the first list. This must be checked: tree-sitter has grammars for both, and C and C++ programs can be profiled with system tools. See the research task below.

Important difference from TypeScript

ts-morph resolves a call site to the exact declaration through the TypeScript compiler. tree-sitter only parses syntax. It does not resolve names across files, imports, or types. Version 2 must decide how to resolve calls for each language, and must label an edge that is only a guess differently from an edge that is resolved exactly. This is the main design risk of this issue.

Research task (first step, before any code)

For each language in the list above, find out:

  1. Which profiling tool the language community uses.
  2. Which profile file format that tool writes.
  3. Whether that tool can write pprof directly.
  4. Which converter exists to turn the other profile formats into pprof.
  5. For tree-sitter: how good call resolution can be for that language.

The result should be a table in a comment on this issue. The result decides what Codespine version 2 must write itself, and what it can reuse as a library.

Possible outcome

Codespine version 2 would be a library that other products can embed, because it would then optimize code in any language. Two candidates for embedding are Heidrun Code and Heidrun Data.

Open questions

  • Should Codespine version 2 live in this repository, or in a new repository?
  • Which language is the second language to implement after TypeScript?
  • Does Codespine version 2 keep ts-morph for TypeScript, because it resolves names exactly?
Lingua principale
TypeScript
Stelle
7
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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 jeromeetienne/codespine

Tutte le issue di jeromeetienne/codespine

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.