Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singleton datatypes are inefficiently wrapped in interfaces in Go #1214

Open
tchajed opened this issue May 4, 2021 · 0 comments · May be fixed by #1394
Open

Singleton datatypes are inefficiently wrapped in interfaces in Go #1214

tchajed opened this issue May 4, 2021 · 0 comments · May be fixed by #1394
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

Comments

@tchajed
Copy link
Contributor

tchajed commented May 4, 2021

Every Dafny datatype is compiled to a Go struct which embeds an interface 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.

@keyboardDrummer keyboardDrummer added lang: golang Dafny's transpiler to Go and its runtime area: performance Performance issues labels Jul 8, 2021
@tchajed tchajed linked a pull request Aug 27, 2021 that will close this issue
@robin-aws robin-aws added the kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny label Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants