Singleton datatypes are inefficiently wrapped in interfaces in Go #1214
Labels
area: performance
Performance issues
kind: enhancement
Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny
lang: golang
Dafny's transpiler to Go and its runtime
Every Dafny datatype is compiled to a Go
struct
which embeds aninterface
that has some methods to determine which constructor was used. Datatypes with a single constructor still have this wrapping even though there's only one implementation of the interface (and there can only be one because the interface has private, unexported types).This interface requires an allocation because it wraps the struct in a pointer, but this makes small structs needlessly inefficient. I have a large project where I got a throughput benchmark to go from 11 files/sec to 120 files/sec just by not embedding the interface and using the struct type directly for a handful of heavily constructed structs.
If it would help I can construct a small benchmark.
The text was updated successfully, but these errors were encountered: