Closed HuwCampbell closed 8 years ago
That's a pretty substantial speedup. Quick question: is it just the composition with final
that's slowing it down, or is scan
not getting inlined?
@acowley IMHO, (~>)
is at fault. That function isn't as fast as its pipes
counterpart for instance.
I think it's that it's yielding a lot of intermediate values and discarding them, it's faster to just not yield them.
Yeah, that's the kind of thing that gets eaten up by RULES most of the time. We could probably do something specific for rewriting uses of final
to avoid the machine composition. IIUC, this is the relevant pipes
correspondence. Is it actually doing anything terribly more efficient? (I honestly don't know)
The specific benchmark that @HuwCampbell is looking at is also kind of interesting as there's just not a lot to it. We should perhaps sprinkle INLINABLE pragmas more generously to crunch down on concrete types.
EDIT: I'd also vote for @HuwCampbell's patch, btw, as it's not worth paying any penalty on something as central as fold
.
I don't see any reason not to accept this, although it seems to point to deeper efficiency concerns.
Sorry for the bikeshedding, I wasn't sure if I should put this forth as fold was already rather elegant using scan, but I got a pretty decent improvement in benchmarks: Before:
After: