Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
inline pragmas for free #21
A little inlining goes a long way in terms of performance---roughly 15%.
This PR adds
Benchmark results before:
Benchmark results after:
This is part of a bigger project to improve freer's performance. I want to record my attempts here, because it seems like as good a place as any:
After inlining this stuff, the major cost centers become
But this is curious!
I went down a rabbit hole on this---presumably the high allocations from
I haven't yet gone down this road, but my next idea is to implement the
Thank you for doing this work, it’s much appreciated.
One thing I worry about is the nature of the microbenchmarks—I wouldn’t be shocked if the inlining were to help in such tiny pieces of code (which create effects and immediately run them) but would be less helpful in real programs (where the inliner is likely to be less aggressive, and the extra inlining might not expose any additional optimizations). I realize this is harder to measure, but have you tried benchmarking your changes on a real program of your own that uses
This is certainly a concern; unfortunately I don't have any real-world
To be honest however; I'm in the middle of writing a guide on why
I'm OK holding off on merging this PR---the fact that it exists is probably enough fuel for me for now; "look, here's a PR that gives you 15% improvement in microbenchmarks" should be enough to show people that this isn't fundamentally an issue, so much as an active area of research and optimization.
This project is on the back burner for me right now, so I don’t think I can spare the time to proactively find some better benchmarks, but I’m also still invested in keeping this project maintained, so I don’t want to give the appearance of complete apathy. I appreciate any and all efforts towards making this library better!
Given it’s marketing you’re talking about, I feel I’d be remiss not to mention @robrix’s fused-effects, as it seems to be extremely fast while still being, fundamentally, an extensible effects system. While it doesn’t seem obviously possible to get freer-simple’s nice API using those techniques, I’m not sure that this is fundamental. Maybe we just need some more help from GHC in a way we haven’t quite figured out yet.