Skip to content

Comments

Add optimization that fuses together map functions#116

Draft
jfmengels wants to merge 48 commits intomdgriffith:masterfrom
jfmengels:fusion
Draft

Add optimization that fuses together map functions#116
jfmengels wants to merge 48 commits intomdgriffith:masterfrom
jfmengels:fusion

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