microsoft / microsoft/TypeScript
Using pointer address as node/symbol id
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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.
```go
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia leggendo gli esempi GetNodeId e GetSymbolId, quindi esamina il modo in cui KeyBuilder rappresenta gli ID. Esegui hereby test per riprodurre la baseline segnalata; l'issue non definisce criteri di accettazione oltre alla discussione degli effetti su memoria, prestazioni, dimensione delle chiavi e ordinamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- go
- 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