perf(npm/csharp): a child chain is derived for every node with a parameter list

Aperta Adatta ai principianti
#1,879 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp, rust

Direzione di ricerca

Leggi src/metrics/npm/csharp.rs e il guard Java descritto nell’issue, poi esamina the_member_walks_derive_a_chain_per_body_not_per_node e member_walk_siblings::FIXTURES in src/observation_tests.rs. Controlla il tipo di nodo C# prima di derivare una catena di nodi figli, quindi estendi il guard a C# o alle righe del fixture; il lavoro è terminato quando il conteggio C# per body corrisponde al comportamento previsto senza regressioni nel guard esistente.

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

Descrizione

low-priority performance

Summary

C#'s Npm::compute derives a child chain for every node that has a parameter_list child, before it knows the node is a type declaration. A class with 65 methods derives 67 chains where the other languages derive 2.

Measured

Counted with child_chains_derived over Ast::metrics with only Npa and Npm selected, on a class body of 65 units. Measured on the local branch refactor/1871-sibling-followups (not pushed) at e0cc1918, whose base is 68b70b08; the C# code is unchanged from main:

Language Unit Chains derived
Java int x; and void m() {} 2
Kotlin val x = 1 and fun m() {} 2
C++ int x; and void m() {} 2
C# public int x; and void M() {} 67

The fixture table is member_walk_siblings::FIXTURES in src/observation_tests.rs.

Cause

src/metrics/npm/csharp.rs asks the primary-constructor question (#1828) of every node it is handed:

if let Some(list) = node.first_child(|id| id == ParameterList)
    && func_opener::is_callable(&list, code, ancestors.of_children(node).get())

A method_declaration has a parameter_list child, so the chain is derived for each method, then the row's parent gate answers "not under a type declaration" and the chain is dropped.

Cost

One allocation per method, constructor, local function and delegate. A derivation has been one allocation since #1805, so this is a constant factor that the scaling gate cannot price. It is the shape the_member_walks_derive_a_chain_per_body_not_per_node guards for Java only (lesson 103).

Suggested fix

Test the node's kind (the type declarations a primary constructor can sit under) before deriving the chain, or read the parent gate's answer from node itself. Then extend the per-body guard to C#, or to every row of the fixture table above.

Related

#1828, #1805, #1696, #1871.

Lingua principale
Rust
Stelle
32
Fork
3
Merge medio
9h 55m
PR unite (30g)
102

Preparare l'ambiente

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 dekobon/big-code-analysis

Tutte le issue di dekobon/big-code-analysis

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.