microsoft / microsoft/TypeScript

Using pointer address as node/symbol id

Abierto
#63,773 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Domain: Performance
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

Nodes and symbols currently store an atomic integer representing their ID, which is lazily assigned upon first use. I was playing with using the pointer addresses as their ID, reducing the size of those structures and avoiding atomic reads on access.

func GetNodeId(node *Node) NodeId {
  return NodeId(uint64(uintptr(unsafe.Pointer(node))))
}

func GetSymbolId(symbol *Symbol) SymbolId {
  return SymbolId(uint64(uintptr(unsafe.Pointer(symbol))))
}

A potential downside is that KeyBuilder will observe larger numbers, requiring additional bytes to represent various keys. It may also affect ordering as IDs will no longer be strictly increasing, but I believe this shouldn't matter given that ID assignment is already non-deterministic.

A quick attempt passes the hereby test and shows a slight reduction in overall memory usage, but I don't have good insight into actual performance benfits/downsides of this approach.

I am opening this as issue instead of PR to discuss, possibly to learn this has been considered and may have been rejected for some reason. I'd be happy to open a PR if desired.

Guía de contribución

Abrir la guía de contribución

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.

Línea de trabajo

Empieza leyendo los ejemplos GetNodeId y GetSymbolId; después, inspecciona cómo KeyBuilder representa los IDs. Ejecuta hereby test para reproducir la línea base informada; el issue no define criterios de aceptación más allá de analizar los efectos sobre la memoria, el rendimiento, el tamaño de las claves y el orden.

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

Evaluación

Stack tecnológico
go
Área
compilers, performance
Tipo de issue
Refactorización
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.