-
Notifications
You must be signed in to change notification settings - Fork 127
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
Alternative defunctionalisation technique #581
Comments
Oh. 😅 My bad; I missed the polyvariance pass in my research. Thanks for the link. I'm a bit surprised though. This paper claims that specialised defunctionalisation is often faster, so I would have expected it to be better for the runtime dispatch to be entirely eliminated. The specialised defunctionalisation technique in that paper doesn't completely eliminate runtime dispatches, but it does try to minimise the number of case variants, so that a higher order function doesn't accumulate case variants when used in different parts of the program. Thanks again for the link! Something for me to play around with. |
The Unrestricted polyvariant duplication can lead to unacceptable code growth and I don't believe that you will be able to completely eliminate the need for some runtime dispatch (in Standard ML). Rust's monomorphisation and treatment of the The Lambda Set Specialization paper is on by "to read" shortlist, since it does offer some evidence that more aggressive specialization up front would be a performance win. |
Hi there,
I was implementing a trie/prefix tree data structure (here) and, while considering how to implement fold on the data structure, I think I noticed a conceptually simple defunctionalisation technique that doesn't require runtime dispatching on a datatype.
The kind of transformation I have in mind would turn the higher-order function
Vector.foldl
(for example) from:Vector.foldl (fn (elt, acc) => elt + acc)
to:
so that MLton's defunctoriser in the elaborate pass doesn't need to construct a sun type over every higher order function and dispatch to the appropriate function at runtime.
I would like to have a go at implementing this kind of optimisation in MLton myself, but I might give up considering my total inexperience with coding compilers 😅 so I thought it wouldn't be bad to post it here in the event I get frustrated and fail, and there is interest from others in implementing the idea.
The transformation looks general to me (can mutate values in the environment record if user wants) and doesn't seem to require anything fundamentally novel to implement, but I would be interested in hearing criticism if it's not possible too.
The text was updated successfully, but these errors were encountered: