-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
TRMC implementation of @ #11859
TRMC implementation of @ #11859
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. If you are in the mood I left a few suggestions to improve the docs.
A minor point: if you observe a slowdown with TMC functions on semi-large lists, it is probably caused by the benchmarking setup. In the regime where the list length is close to the minor heap size, you can observe artifical promotion effects. See the "Promotion" section of #9760 (comment). In short: if you are "ignoring" the result of the function call in your benchmark, you should store it into a long-lived reference instead for more realistic promotion behavior (in general, the result of operations on very large inputs do stay alive until after the next minor collection). |
Thanks for the suggestion. I tried this and now the benchmark shows that the new version is always at least a smidgen faster than the existing implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This looks good to go, but still needs a second official approval. Perhaps @gasche can do the honours? |
@yallop: do you mind if I squash-merge your PR? I normally squash-merge small PRs as it is easier to cherry-pick them, revert them, etc, but since you took care to have a clean history, perhaps you have a preference for doing a plain merge... |
Thanks for asking, @nojb! I'm happy to have it squash-merged. |
Thanks, merged! |
A tail-recursive-modulo-cons implementation of
Stdlib.(@)
(andList.append
), replacing the existing stack-consuming implementation.To avoid a slowdown over the existing version, the function is also unrolled. (It's worth noting, though, that this isn't the fastest possible implementation: an unrolled stack-consuming version would be even faster.)
Benchmark results:
Almost always faster than the current implementation; always faster on lists of length less than 16384; twice as fast on long lists