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

Abierto Apto para principiantes
#1,879 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
csharp, rust

Línea de trabajo

Lee src/metrics/npm/csharp.rs y la guarda de Java descrita en el issue; luego inspecciona the_member_walks_derive_a_chain_per_body_not_per_node y member_walk_siblings::FIXTURES en src/observation_tests.rs. Comprueba el tipo de nodo de C# antes de derivar una cadena de nodos secundarios y, después, amplía la guarda a C# o a las filas del fixture; el trabajo estará terminado cuando el recuento de C# por cuerpo coincida con el comportamiento esperado sin que haya regresiones en la guarda existente.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
32
Forks
3
Merge medio
9 h 55 min
PR fusionados (30 d)
102

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dekobon/big-code-analysis

Todos los issues de dekobon/big-code-analysis

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.