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

Add optimization that fuses together map functions #116

Draft
wants to merge 48 commits into
base: master
Choose a base branch
from

Conversation

jfmengels
Copy link
Contributor

@jfmengels jfmengels commented May 4, 2023

The idea of this optimization is to avoid having consecutive map functions, and instead grouping them using composition. So instead of:

x |> List.map f1 |> List.map f2

we'd in practice end up with

x |> List.map (f1 >> f2)

Some benchmarks can be found in this folder: https://github.com/jfmengels/elm-benchmarks/tree/master/src/FusionExploration
It seems to be worthwhile to have, as shown for instance by this benchmark:

Function composition like this has its own performance drawbacks compared to lambdas, but that's where #73 can come in and save the day.

I made this branch a long time ago, and I don't remember where it's at, or why I didn't end up creating a PR for it. So I'll just make a draft and then other people can see it or take inspiration from it. Ping me to put eyes on it again when some time gets unblocked for this project.

@kutyel
Copy link

kutyel commented May 4, 2023

Very nice to see the performance benchmarks, thanks for this! 💪🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants