Closed
Description
The itertools equal function expresses the same functionality as Iterator::eq
in a way that compiles better / performs better. Import their implementation into libstd, also see if other iterator comparison functions can be improved.
The problem could be that the libstd code is using match
on a tuple of options.
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Issue: Problems and improvements with respect to performance of generated code.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
bluss commentedon Sep 20, 2017
The itertools code is not the end station of course, there could be improvements on top of that.
mister-walter commentedon Sep 21, 2017
I'd like to take a shot at this - I'll go check out Gitter when I have time later today (I'm currently on JST)
lezgomatt commentedon Oct 1, 2017
hey @mister-walter, are you still interested in working on this? If not, I'd like to give this issue a try 😃
bluss commentedon Oct 1, 2017
Feel free to find me on irc or here
mister-walter commentedon Oct 1, 2017
lezgomatt commentedon Oct 1, 2017
Awesome, thanks!
I tried a few approaches out and it seems that the matching on the tuples does indeed cause slower code to be generated (best on some quick benchmarking).
The current implementation does the ff:
Modifying the code to separate the matching resulted in some nice gains:
Alternatively (to reduce nesting):
I haven't taken a good look at the MIR generated though. I also tested it out on the other comparison functions and noticed similar gains. I'll try to take a deeper look at the code generated soon.
bluss commentedon Oct 1, 2017
Oh nice, the new versions are side-effect compatible as well right? self.next() and other.next() are called exactly as many times as before.
11 remaining items